<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
alert(123);
$.ajax({
type: "post",
async: false,
url: "http://xxx.xxx.xxx.xxx:8080/charge/wap-charge-input.action",
dataType: "jsonp",
jsonp: "callback",
jsonpCallback:"flightHandler",
success: function(json){
alert(json);
},
error: function(){
alert('fail');
}
});
});
</script>执行结果:alert(fail);
它怎么执行的就是error呢,谁知道什么原因么?怎么解决,谢谢大家。jsonpjQuery AjaxJSON函数
<script type="text/javascript">
$(document).ready(function(){
alert(123);
$.ajax({
type: "post",
async: false,
url: "http://xxx.xxx.xxx.xxx:8080/charge/wap-charge-input.action",
dataType: "jsonp",
jsonp: "callback",
jsonpCallback:"flightHandler",
success: function(json){
alert(json);
},
error: function(){
alert('fail');
}
});
});
</script>执行结果:alert(fail);
它怎么执行的就是error呢,谁知道什么原因么?怎么解决,谢谢大家。jsonpjQuery AjaxJSON函数
jsonpCallback:"flightHandler" 如果没有flightHandler函数,jquery会自己执行次函数的。
在后面写一个flightHandler也不行。
嗯,谢谢,解决了,原因返回json的数据有问题,
jquery在回调flightHandler函数接受到的json数据应该如下:
flightHandler({"account":"XX","passed":"true","error":"null"})
而我返回的json的数据是:flightHandler{"account":"XX","passed":"true","error":"null"} ,jquery执行flightHandler函数时没有找到该函数,所以报error。
谢谢大家。