look at this function please
$(".menu_tree img.edit").click(function()
{
id = this.id;
lang = '<?=$lang_id?>';
var body_width = $("body").width();
var body_height = $("body").height();
$("#shadow").width(body_width);
$("#shadow").height(body_height);
$("#shadow").show();
var width = $("#edit_title").width();
var height = $("#edit_title").height();
$("#edit_title").height(0);
$("#edit_title").width(0);
$("#edit_title").animate(
{
width: width,
height: height
},600);
$.post
(
"get_title.php",
{id: id, lang: lang},
function(data)
{
alert("qqq");
},
"json"
);
});
in get_title.php i generate json object, something like {name:"name",val:"value"}
it works fine if i don’t wrote "json", but with "json" it even doesn’t alert my qqq🙁
Any ideas?
Thanks
The 1.4.2 parser is more strict than earlier versions. As noted by michal, that json is not valid because the property names are not double quoted. I was bit by this issue recently when upgrading a site to jQuery 1.4.2.
I strongly suggest allowing PHP to take care of json encoding for you. My problem, which I suspect is yours as well, was that I was putting together json strings manually in PHP, and jQuery was rejecting it because some were single quoted.
So, for the PHP rather than something like
let PHP do the encoding:
also, adding a Content-Type header for JSON can’t hurt if you aren’t already.