`
wangchengyong
  • 浏览: 24134 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
文章分类
社区版块
存档分类
最新评论

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"}]});
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics