nimi nimi - 6 months ago 85
jQuery Question

jQuery Ajax call No element found issue

I am getting a javascript error on firefox 3.5, when trying to call an ajax method.

Please find the error below:

XML Parsing Error: no element found Location: moz-nullprincipal:{1a2c8133-f48f-4707-90f3-1a2b2f2d62e2} Line Number 1, Column 1:

^


this is my javascript function:

function Update(Id) {
$.ajax({
type: "GET",
url: ROOT_URL + "/sevice/udates.svc/Update?Id=" + Id,
success: function(response) {

},
async: false
});
}

Answer

The ajax call expects XML back (perhaps due to bad guessing) and tries to parse it and fails if nothing is returned or it is not valid XML..

Use the dataType option to specify the format of the response.


From the comments it looks like some browsers cannot handle an no-content response. So, a workaround for such cases might be to return something from your service (even a single space).

Comments