Jquery和Ajax - xml文件的问题 [英] Jquery and Ajax - problem with xml file
本文介绍了Jquery和Ajax - xml文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码中的问题是什么?我正在尝试在网页(HTML)中加载一部分xml文件,我尝试在synax下面但它不起作用。如果有更好的方式告诉我。
what is the problem in the below code. i'm trying to load a part of xml file in a webpage(HTML) and I tried below synax but it doesn't work. If there is better way tell me.
$.ajax({
type: "GET",
url: "http://www.xmlfiles.com/examples/note.xml",
dataType: "xml",
success: function(xml){
$(xml).find('note').each(function(){
var to = $(this).find('to').text();
console.log(to);
});
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
推荐答案
.ajax({
type: GET,
url: http://www.xmlfiles.com/examples/note.xml,
dataType: xml,
成功: function (xml){
.ajax({ type: "GET", url: "http://www.xmlfiles.com/examples/note.xml", dataType: "xml", success: function(xml){
(xml)。 find(' note')。each( function (){
var to =
(xml).find('note').each(function(){ var to =
( this ).find(' to')。text();
console .log(to);
});
},
错误: function (){
alert( 处理XML文件时发生错误。);
}
});
(this).find('to').text(); console.log(to); }); }, error: function() { alert("An error occurred while processing XML file."); } });
这篇关于Jquery和Ajax - xml文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文