When I submit an angularjs $http
GET call I receive an XML parsing error.
The $http call code snippet is:
$http({
method: 'GET',
url: "myapp/api/items" + itemId
});
The error is:
XML Parsing Error: no element found Location: moz-nullprincipal:{f191853f-5581-b049-b83f-5f4b69211adb} Line Number 1, Column 1:
The data being returned is JSON. If I put the URL in a browser then the request is submitted and the response data comes back successfully in the browser.
I tried adding responseType: 'json'
(and responseType: 'application/json'
) to the $http
call with no success. (I referenced the Usage section in angularjs http doc to determine how to configure the call.)
Is there a way I can force the response data to be recognize as json to avoid that error?
If you are using Mozilla Firefox, install firebug and try to inspect the http GET in the Net panel or in the Console panel.
In the headers tab you can check the Content-Types being sent and received. Maybe the problem is in the server-side response's content-type.
May be you are running your app in file:///
, since this is AJAX request this can be happen. If you have installed nodejs, you can install a server and see console log.
To install a server on nodejs
npm install -g http-server
And go to(cd
into) your project directory and:
http-server -o. -o
Now see the browser console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With