ajax跨域请求返回的数据出错



我正在创建一个网络应用程序,需要在地图上显示信息。但我需要将堇青石从EPSG:3301转换为EPSG:4326。有一个网站你可以做http://spatialreference.org/projection/?json={"几何体":{"类型":"点","坐标":[5527742.81,6561591.74]};inref=EPSG:3301&outref=EPSG:4326。所以我有我的代码:

$("#btn1").click(function(event){
var searchString    = $('input[name=check_list1]:checked', '#myForm').val();
var data1            = 'search='+ searchString;
if(searchString) {
    $.ajax({
        type: "POST",
        url: "do_search.php",
        data: data1,
        dataType: 'json',
        success: function(data){
            var otsing_data = (data);              
            var json_url = "http://spatialreference.org/projection/?json={'geometry':{'type':'Point', 'coordinates':["+otsing_data['x']+", "+otsing_data['x']+"]}}&inref=EPSG:3301&outref=EPSG:4326";
            $.ajax({
               type: 'GET',
                url: json_url,
                async: false,
                contentType: "application/json",
                dataType: 'jsonp',
                }).done(function (data) {
                var test = data;
                console.log(test);
            });
      }
    });    
} 
//  return false;
})

但是console.log(测试)返回

Object {error: "Expecting property name: line 1 column 1 (char 1)"}

我需要更改

var json_url = "http://spatialreference.org/projection/?json={'geometry':    {'type':'Point', 'coordinates':["+otsing_data['x']+", "+otsing_data['x']+"]}}&inref=EPSG:3301&outref=EPSG:4326";

var json_url = 'http://spatialreference.org/projection/?json={"geometry":{"type":"Point", "coordinates":['+point_x+', '+point_y+']}}&inref=EPSG:3301&outref=EPSG:4326';

相关内容

  • 没有找到相关文章

最新更新