i am currently working on a program in jquery. My program works fine in firefox 3.5 but not until i upgraded my browser to firefox 4.0. Since then, the ‘parsererror’ never failed to show and it gives me a bad headache.
I’ve notice that this is the part of my code that FIRST ‘parsererror’ shows:
$(document).ready( function() {
...
$.ajaxSetup({
timeout: 10000,
error: function(xhr, msg, e) {
showMessage('HTTP error: ' + JSON.stringify(msg) + '.'); //this is the parsererror
}
});
.
.
})
And not only that, my dynamic tab no longer appear in my page. I notice that everytime if remove this line ‘<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>‘, it appears but my other jquery element is no good. I don’t know what’s wrong. Maybe it some sort of incompatibility issues, but i just dont where to start fixing. Please help.
EDIT:
this is the json it returned. This is supposedly for my dynamic menu that will create tab Evry menu you clicked. But this doesn’t show.
[
{"title": "File","submenus":[
{"title": "Open","submenus":[]},
{ "title": "New", "submenus":[]},
{ "title": "Save as", "submenus":[]},
{ "title": "Save", "submenus":[]}
]},
{ "title": "View","submenus":[]},
{ "title": "viewAll", "submenus":[]},
{ "title": "Close","submenus":[]},
{"title":"jQgrid", "submenus":[]}
]
Description from jQuery Ajax’s error documentation
In your code you have
Looking at the jQuery docs, you will see that the second argument is a string and not a JSON object like you are expecting it to be. The parser is seeing the string and throws the parse error that you are seeing.
Now if an error is occurring and the object is saying that there is an error. JSON requires that the name has double quotes around it. So people think:
is valid JSON, but it is not. The following is valid.