Update database without reloading page

merk51

New Member
Ive just had some fantastic help from Sandeepan, thank you!Please can anyone see what I have done wrong with this ....\[code\]<head><script type="text/javascript" src="http://stackoverflow.com/questions/3631736/jquery-1.4.2.js"></script><script type="text/javasript">function addItemToUsersList(itemId){ $.ajax({ 'url': 'member-bucketadd-execTEST.php', 'type': 'GET', 'dataType': 'json', 'data': {itemid: itemId}, 'success': function(data) { if(data.status) { if(data.added) { $("span#success"+itemId).attr("innerHTML","Item added to your personal list"); } else { $("span#success"+itemId).attr("innerHTML","This item is already on your list"); } } }, beforeSend: function() { $("span#success"+itemId).attr("innerHTML","Adding item to your bucketlist..."); } 'error': function(data) { // what happens if the request fails. $("span#success"+itemId).attr("innerHTML","An error occureed"); }}); } </script></head>\[/code\]Then the button to activate the function in :\[code\] <a onclick='addItemToUsersList("<?php echo $itemid ; ?>")'> Add<img src='http://stackoverflow.com/questions/3631736/images/plus-green.png' /> </a>\[/code\]and the exec page:\[code\]<?php if($bucketlist < 1) { mysql_query("INSERT INTO membersbuckets (memberbucketid, userid, bucketid, complete) VALUES ('', '$userid', '$_GET['itemId]', '0')"); return json_encode(array("status" => true, "added" => true)); } else { return json_encode(array("status" => true, "added" => false)); }//echo "You are being directed to your bucket list, please wait a few moments...<meta http-equiv='Refresh' content='2; URL=mybucketlist.php'/>";?> \[/code\]The links are showing up as links but nothing happens when I click them!! Here is the test page I am working on http://olbl.co.uk/showbucketsTEST.phpThank you in advance!
 
Back
Top