【发布时间】:2016-08-26 01:06:13
【问题描述】:
我的工作包括使用 Ajax 在 html 文件中读取这个遥远的 xml 文件:http://www.velib.paris/service/stationdetails/paris/901! 这是我的代码:
<script type="text/javascript">
getReadXmlFile();
function getReadXmlFile(){
alert("recherche d fichier");
$.ajax({
type: "GET",
url: "http://www.velib.paris/service/stationdetails/paris/901",
dataType: "xml",
success: parseXml
});
alert("obtention du fichier");
}
function parseXml(xml){
alert('debut du parse');
var up=$(xml).find("updated").text();
alert(up);
}
</script>
但它不运行我不知道为什么 感谢您的帮助!我需要你的帮助!
【问题讨论】:
-
“它不运行”是什么意思?有什么错误吗?看起来这是因为您正在执行异步调用,并且您的
parseXml函数在 AJAX 返回任何内容之前正在运行。查看此答案以获取有关如何在执行异步调用后创建函数的示例:stackoverflow.com/questions/9337168/…