我想从这个XML(http://stagservices.upol.cz/ws/services/rest/student/getStudentInfo?osCislo=R140742)取回“jmeno”,每次都会收到错误。
$(document).ready(function () {
$.ajax({
type: 'GET',
url: 'http://stagservices.upol.cz/ws/services/rest/student/getStudentInfo?osCislo=R140742',
crossDomain: true,
dataType: "jsonp",
success: parseXml,
error: function () {
alert("Error: Something went wrong");
}
});
});
function parseXml(xml) {
$(xml).find('student').each(function () {
$("#output").append($(this).find('jmeno').text() + "<br />");
});
}
答案 0 :(得分:0)
<强> DEMO 强>
使用datatype: 'xml'
。
$(document).ready(function () {
$.ajax({
type: 'GET',
url: 'http://stagservices.upol.cz/ws/services/rest/student/getStudentInfo?osCislo=R140742',
crossDomain: true,
dataType: "xml",
success: function(data){
console.log(data);
},
error: function () {
alert("Error: Something went wrong");
}
});
});