我正在尝试读取url提供的xml数据。
网址:http://api.simplyhired.co.in/a/jobs-api/xml-v2/q-java/l-hyderabad/ws-10?pshid=46408&ssty=3&cflg=r
但是我没有从url得到任何响应数据。我尝试了下面的代码:
var url = "http://api.simplyhired.co.in/a/jobs-api/xml-v2/q-java/l-hyderabad/ws-10?pshid=46408&ssty=3&cflg=r";
$.ajax({
url: url,
complete: function(data) {
alert(data.responseText);
}
});当我在浏览器中打开url时,它以xml格式显示数据。即使在对url进行编码之后,该问题仍然存在。
有没有更好的方法来做这件事?
谢谢。
发布于 2012-10-26 15:51:47
试试这样的东西
$.ajax({
type: "GET",
url: "www.mysite.com/file.xml",
dataType: "xml",
success: function(xml) {
#do work here if success
}
});如果这仍然不起作用,请注意你的url,它有一些字符需要编码(例如,"=“表示编码的是"%3D")
查看此处了解JQuery URI编码:http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp
https://stackoverflow.com/questions/13082682
复制相似问题