欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery Ajax實(shí)現(xiàn)跨域請(qǐng)求

 更新時(shí)間:2017年01月21日 08:33:53   作者:itdream6  
這篇文章主要為大家詳細(xì)介紹了jQuery Ajax實(shí)現(xiàn)跨域請(qǐng)求的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了jQuery Ajax跨域請(qǐng)求的具體代碼,供大家參考,具體內(nèi)容如下

html 代碼清單:

<script type="text/javascript" src="http://www.youxiaju.com/js/jquery-1.4.2.min.js"></script> 
<script type="text/javascript"> 
$(function(){ 
$.ajax( 
  { 
    type:'get', 
    url : 'http://www.youxiaju.com/validate.php?loginuser=lee&loginpass=123456', 
    dataType : 'jsonp', 
    jsonp:"jsoncallback", 
    success : function(data) { 
      alert("用戶名:"+ data.user +" 密碼:"+ data.pass); 
    }, 
    error : function() { 
      alert('fail'); 
    } 
  } 
); 
}) 
</script> 

服務(wù)端 validate.php 代碼清單:

<?php 
header('Content-Type:text/html;Charset=utf-8'); 
$arr = array( 
  "user" => $_GET['loginuser'], 
  "pass" => $_GET['loginpass'], 
  "name" => 'response' 

); 
echo $_GET['jsoncallback'] . "(".json_encode($arr).")";

效果圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論