用搜狐地图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>
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>
动态指定src=http://api.go2map.com/engine/api/ipcity/json 没有区别,你这里虽然在网络工具里看到,但是没法输出!
response.write("{\"p1\":\"v1\"}")
用 jsonp 的时候
response.write(request["callback"] + "({\"p1\":\"v1\"})")