Ajax 의 jsonp 방식 으로 도 메 인 을 넘 어 데 이 터 를 가 져 오 는 간단 한 인 스 턴 스

jsonp 호출,오늘 만 났 어 요.마침 정 리 했 어 요.

<!DOCTYPE html>
<html>
<head>
	<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
 <script type="text/javascript">
	$(document).ready(function(){
	 $("#b01").click(function(){
	 	$.ajax({//danielinbiti.txt    :getAInfo(["<input type='text' value='1222'/>"])
    url: 'http://192.168.12.21:8080/systemr/danielinbiti.txt',
    dataType: 'jsonp',//    jsonp
    processData: false,
    jsonpCallback:'getAInfo',//     getAInfo  
    type: 'get',
    success: function(data) {
      $("#myDiv").html(data);
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
      alert('error');
      alert(XMLHttpRequest.status);
      alert(XMLHttpRequest.readyState);
      alert(textStatus);
    }
   });
	 });
	 $("#b02").click(function(){//        request  callback,   callback(     json  )     ,getJSON ajax   ,   json  
	 	 $.getJSON("http://192.168.12.21:8080/systemr/b.do?jsoncallback=?",function(result){
		   $("#myDiv").html(result);
		  });
	 });
	});
</script>
</head>
<body>

<div id="myDiv"><h2>   AJAX     </h2></div>
<button id="b01" type="button">    01</button>
<button id="b02" type="button">    02getJSON</button>

</body>
</html>
이상 의 Ajax 의 jsonp 방식 으로 도 메 인 을 넘 어 데 이 터 를 얻 는 간단 한 인 스 턴 스 는 바로 작은 편집 이 여러분 에 게 공유 하 는 모든 내용 입 니 다.참고 가 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기