用搜狐地图api
ip城市请求,因为跨域,所以用jsonp,从firebug中看已经获取到数据了,但是总是执行error里的方法<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
   jQuery(document).ready(function(){
         $.ajax({
             async:false,
             url : "http://api.go2map.com/engine/api/ipcity/json",
             dataType : "jsonp",
             jsonp: "callbackparam",
             jsonpCallback:"success_jsonpCallback",
           success : function(data){
               alert(data);
             },
             error:function(){
                 alert('error');
             }
         });
   })       
</script>
http://api.go2map.com/engine/api/ipcity/json
</body>
</html>

解决方案 »

  1.   

    jsonp跨域的部分不是一般不是个返回个对于回调函数的请求,然后在本地定义好的script中执行这个, 这里直接指定个json 这个和直接append个script标签再
    动态指定src=http://api.go2map.com/engine/api/ipcity/json 没有区别,你这里虽然在网络工具里看到,但是没法输出!
      

  2.   

    后台服务器响应的内容有区别的用 json 的时候
    response.write("{\"p1\":\"v1\"}")
    用 jsonp 的时候
    response.write(request["callback"] + "({\"p1\":\"v1\"})")