Reputation: 63
I am trying to read XML from a crossdomain source and im having trouble getting the callback response into a string. If i look at the console in chrome i get 'Resource interpreted as Script but transferred with MIME type text/xml: http://mysite.com:2000/g7?callback=jQuery17209426668137311935_1344441190139&_=1344441194148'
Then followed by 'Uncaught SyntaxError: Unexpected token <'
What am i missing here?
$.ajax({ type: 'GET', url: 'http://mysite.com:2000/g7', dataType: 'jsonp', mimeType: 'text/xml' });
Upvotes: 1
Views: 996
Reputation: 1038710
What am i missing here?
The fact that JSONP infers JSON response wrapped in a callback. This cannot work with XML. So you will have to modify the remote server side script so that it returns JSONP, not XML. For example the response could look like this:
callback({ xml: '<node>foo bar</node>' });
But if the remote server sends directly XML you cannot use AJAX to invoke it due to the same origin policy restriction.
Upvotes: 2