Ajax 跨域请求简单例子

来源:互联网 发布:网络穿透技术 编辑:程序博客网 时间:2024/05/18 03:47



$.ajax({  
                 type: "post", 
                 contentType: "application/x-www-form-urlencoded",
                 dataType:"jsonp",
                 url: "https://api.map.baidu.com/geocoder/v2/",  
                 data: {"ak": "6tYzTvGZSOpYB5Oc2YGGOKt8","output":"json","address":addressuri} ,
                 success: function (result) {  
                //var lon = data.result.location.lng;
                //var lat = data.result.location.lat;
                alert(result.result.location.lng);
                //alert(lon);
                 },  
                 error: function (XMLHttpRequest, textStatus, errorThrown) {
                  alert(errorThrown);
                 }
             });



原创粉丝点击