I've just upgraded from version 1.4 to version 1.5 of jQuery, and now my AJAX calls always fail with the "invalid label" error.
An example request is:
jQuery.ajax({
async: false
, dataType: "json"
, error: function (xhr, status, error) { ... }
, success: function (data, status, xhr) { ... }
, type: "post"
, url: "ajax/request.asp"
});
On the net I found this error is raised when the returned JSON is not wrapped with jQuery's callback (e.g. jQuery1234({ "something": "abcd" })
.
The problem is I'm returning a JSON, not a JSONP (and I state it in the AJAX request), so why I must specify a callback in the returned JSON?
The 1.5 changelog says nothing about this... (Or it's me who can't read?)
Update:
This is an example of a not working JSON:
{
"esito":"Ok",
"centriCosto":[
{
"id":"1",
"descrizione":"Colazione"
},
{
"id":"2",
"descrizione":"Pranzo"
},
{
"id":"3",
"descrizione":"Cena"
}
]
}
And this is the same callback-wrapped working JSON:
jQuery1502710949228847014_1296739130498({
"esito":"Ok",
"centriCosto":[
{
"id":"1",
"descrizione":"Colazione"
},
{
"id":"2",
"descrizione":"Pranzo"
},
{
"id":"3",
"descrizione":"Cena"
}
]
})
By the way, Firebug says both of them are valid JSONs (and he's very picky about correctness).
looks like this is fixed now in v1.6 - had the same issue after upgrading to ver 1.5.1 & after upgrading to 1.6 the issue disappeared.
Here's the solution: