jQuery AJAX 跨域请求

跨域请求 只要 dataType : 'jsonp',  jsonp:"jsoncallback",  然后返回一个json格式的就可以了

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>|体检系统</title>
</head>
<body>

<script src="http://cdn.bootcss.com/jquery/1.7.2/jquery.min.js"></script>

<script type="text/javascript">
 
$(function(){

$.ajax(  
    {  
        type:'get',  
        url : 'http://www.taobao.com?loginuser=lee&loginpass=123456',  
        dataType : 'jsonp',  
        jsonp:"jsoncallback",  
        success  : function(data) {  
           alert(data)
        },  
        error : function() {  
            alert('fail');  
        }  
    }  
);  
});
</script>


</body>

</html>

 

posted @ 2017-06-30 11:34  freedom/cn  阅读(153)  评论(0编辑  收藏  举报