我使用此脚本使用jQuery解析 XML文件,但只有在本地服务器中有 XML文件时才会运行.您知道如何解析远程服务器上的XML文件吗? script$(document).ready(function(){ $.ajax({ type: "GET", url: "http://www.m
<script>$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://www.myotherwebsite.com/folder/myfile.xml",
dataType: "xml",
success: function(xml){
$(xml).find("user").each(function(){
var name = $(this).find("name").text();
var email = $(this).find("email").text();
var phone_number = $(this).find("mobile").text();
document.write("<b>Name</b>: "+name+"<br>");
document.write("<b>Email</b>: "+email+"<br>");
document.write("<b>Phone Number</b>: "+phone_number+"<br>");
})
}
});
});
</script>
Same Origin Policy会阻止远程访问.
