Ok so I am working on a project and i'm trying to return JSON to an AJAX call... however it isn't working
Code:
$("a.link-delete-hate").click(function() {
var hateid = $(this).attr("id").substr(6);
$.ajax({
type: "POST",
url: "/ajaxfuncs.php",
data: "do=delete&format=json&hate_id=" + hateid,
dataType: "json",
// contentType: "application/json; charset=utf-8",
success: function(data){
alert("Data: " + data.msg);
$.facebox('' + data.msg + '');
// If no errors, fade out deleted hate.
if(data.error == false)
{
$("#feed_item_" + hateid).fadeOut(1000);
}
}
});
});
Now it should be returning:
Code:
{"error": true, "msg": "Message about call."};
that is sent back with a header of "contentType: "application/json; charset=utf-8"" too...
And yet it seems to return nothing, the thing isnt executed and nothing is returned to the user (no message shown).
Been googling like mad to try and figure out how to properly do this :/
I want to get a JS object of the JSON returned so I can get data.msg and data.error etc :/
Please help. Thanks.
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|