文章来源: 
    
      100素材网
  
  更新时间:
    
   2014-08-11 16:17:45
  
  
  ajax 跨域  jquery ajax跨域  ajax跨域请求 jsonp  跨域请求数据   
     客户端代码
原文地址:http://www.100sucai.com/code/1274.html
 
    <html>
<head>
<script type="text/javascript" src="http://100sucai.com/js/jquery.js"></script>    
<script type="text/javascript">  
$.ajax({
type : "get",
async:false,
url : "http://100sucai.com/img/test/test.php",
//url:"test.php",
dataType : "jsonp",
success : function(data){
alert(data.name);
},
error:function(){
alert('fail');
}
});
</script> 
</head>
<body>
</body>
</html>
服务端代码<?php 
$jsonp = $_REQUEST["callback"];
$str = '{"id":"1","name":"100素材网"}';
$str = $jsonp . "(" .$str.")";
echo $str;
 ?>
除非特别声明,此稿为原稿转载请注明原文链接原文地址:http://www.100sucai.com/code/1274.html
  浏览次数次 
     上一篇文章: php获取网站Alexa值排名的代码 
       下一篇文章: PHP识别用户是通过电脑或手机访问网站代码 
    
                
            

 推荐阅读:
推荐阅读: 
       
       
       
       
       
       
       
      