function addFact(id,event) { if (event) event.preventDefault(); var data = { id: id }; var element = event.target; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post('http://www.australiasbestcity.com.au/my-facts/?action=add', data, function(response) { if (response.result && response.code) { $(element).parent().replaceWith(response.code); } }, 'json'); } function removeFact(id,event) { if (event) event.preventDefault(); var data = { id: id }; var element = event.target; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post('http://www.australiasbestcity.com.au/my-facts/?action=remove', data, function(response) { if (response.result && response.code) { $(element).parent().replaceWith(response.code); } }, 'json'); } function clearFacts() { window.location = 'http://www.australiasbestcity.com.au/my-facts/?action=clear'; }