title: Update database without reloading page
body: <p>Ive just had some fantastic help from Sandeepan, thank you!</p>
  
  <p>Please can anyone see what I have done wrong with this ....</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript" src="jquery-1.4.2.js"&gt;&lt;/script&gt;
  &lt;script type="text/javasript"&gt;
  
  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");
          }
  });
                    }
       &lt;/script&gt;
  
  &lt;/head&gt;
  </code></pre>
  
  <p>Then the button to activate the function in :</p>
  
  <pre><code>   &lt;a onclick='addItemToUsersList("&lt;?php echo $itemid ; ?&gt;")'&gt; Add&lt;img src='images/plus-green.png' /&gt; &lt;/a&gt;
  </code></pre>
  
  <p>and the exec page:</p>
  
  <pre><code>&lt;?php 
  
  if($bucketlist &lt; 1) 
   {
      mysql_query("INSERT INTO membersbuckets (memberbucketid, userid, bucketid, complete)
      VALUES ('', '$userid', '$_GET['itemId]', '0')");
          return json_encode(array("status" =&gt; true, "added" =&gt; true));
   }
   else
   {
          return json_encode(array("status" =&gt; true, "added" =&gt; false));
   }
  
  
  
  //echo "You are being directed to your bucket list, please wait a few moments...&lt;meta http-equiv='Refresh' content='2; URL=mybucketlist.php'/&gt;";
  ?&gt; 
  </code></pre>
  
  <p>The links are showing up as links but nothing happens when I click them!! Here is the test page I am working on <a href="http://olbl.co.uk/showbucketsTEST.php" rel="nofollow noreferrer">http://olbl.co.uk/showbucketsTEST.php</a>
  Thank you in advance! </p>