Hi, I'm just playing around with jQuery and trying something that ought be simple, but it just ain't working.
$(document).ready(function(){
$.ajax({
url : 'http://soiduplaan.tallinn.ee/',
data : {a : 'p.routes', transport_id : 'tram', t : 'xml', l : 'ee'},
error : function(xhr, stat){
alert('error');
},
success : function(data){
alert('success');
alert(data);
}
});
});
The snippet is in a test.js file and included in a test.html file which is opened in Firefox (3.6) like file:///C:/test.html and altough 'success' is shown the data is empty and through Firebug the response for XML displays:
X`ML Parsing Error: no element found Location: moz-nullprincipal:{5ac44e50-2cb6-45d1-9cfe-0b999850ecdb} Line Number 1, Column 1:`
Alternatively I tried that adding
dataType : "text"
has no effect, the result is still processed as xml (probably because the response has content-type: text/xml; charset=UTF-8).
I'm able to see the response results through Firebug if I set
dataType : "script"
but then as it isn't actually a valid js script it simply fails, Firebug displays:
invalid regular expression flag t
<?xml version="1.0" encoding="UTF-8"?>..._days><types><type routes="85" city="t
It gets "better", if do the above request in browser and through "View Source" copy the xml to be validated here http://www.w3schools.com/Dom/dom_validate.asp it displays "no errors found" so why won't it work through xmlhttprequest?
What am I doing wrong?
Would it be possible to somehow force the xmlhttprequest's response to be processed as text/plain?
br, iges
P.S. I've tired the suggested dataType : "html" option (forgot to mention initially), but the "html" also does not work and in Firebug I can see the same error about parsing/moz-nullprincipal.
Also the service providing the xml data is controlled by a third party to which I do not have access, either there is a way to do this or I'll have to kiss my idea goodbye :(