JSONP实现Jquery客户端:aa.htmlhtmlheadscript typetext/javascript idscript1/scriptscri
JSONP实现Jquery
客户端:aa.html
<html> <head> <script type="text/javascript" id="script1"></script><script type="text/javascript">function a() {document.all.script1.src='response.js';}function jsonp_callback(data) {alert(data.RESULT[0].errmsg);document.all.text1.value = data.RESULT[0].errmsg;}//例子function searchCustInfo(){ jQuery.ajax({ url : "http://192.168.101.190:8080/custview/custView/test.jsp", data : {param1:"123456", param2:"wedrftgyhl"}, // 传递参数 dataType: "jsonp", success: function(data) { alert(data.RESULT[0].retno); document.getElementById("conditionValue").value = data.RESULT[0].retno; }, error: function() { alert("网络繁忙,请重试!"); } });}</script></head><body> <input type="button" value="click" onclick="a();"> <input type="text" value="text" name="text1"> </body> </html> 服务端:response.js
jsonp_callback({"RESULT":[{"retno":"-1","errmsg":"该号码不能在此缴费 .错误码:[-1808]","errno":"-1808"}]}); 