Ajax获取XML - Google路线 [英] Ajax Get XML - Google Directions

查看:96
本文介绍了Ajax获取XML - Google路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  var url ='http: //maps.googleapis.com/maps/api/directions/xml?origin=Chicago,IL&destination=Los+Angeles,CA&waypoints=Joplin,MO|Oklahoma+City,OK&sensor=false'; 

$ .ajax({

类型:GET,
url:url,
dataType:xml,
异步:false,
成功:function(xml){

$(xml).find(route)。each(function(){

var startaddresss = $(this).find('start_address').text();

alert(startaddresss);
});
}
});

如果我将XML保存到XAMPP并从AJAX中调用它,它可以正常工作。在过去两周里发生了什么变化?



谢谢 解决这个问题。所以我将使用PHP来获取文件并返回JSON。


I had the following script working two weeks ago in XAMPP, today it doesnt work.

var url = 'http://maps.googleapis.com/maps/api/directions/xml?origin=Chicago,IL&destination=Los+Angeles,CA&waypoints=Joplin,MO|Oklahoma+City,OK&sensor=false';

$.ajax({

type: "GET",
url: url,
dataType: "xml",
async: false,
success: function(xml) {

$(xml).find("route").each(function(){

var startaddresss = $(this).find('start_address').text();

    alert(startaddresss);
});
}
});

If i save the XML to XAMPP and call it from AJAX it works fine. What changed in the last two weeks?

Thanks

解决方案

Cant fix the issue. So i will use PHP to fetch the file and return JSON.

这篇关于Ajax获取XML - Google路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆