【小(xiǎo)編推薦】jquery ajax跨域模闆代碼

2015-08-06   |&nb​♦✔ sp;  發布者:梁國(§←•​guó)芳   |  &±<nbsp;查看(kàn):3320次

前端開(kāi)發
 前台js:
        $.ajaxΩγ ∞({  
         <∏¶     type : "get"$β,  
          &♦↔×‌nbsp;  async:false, &nbs ★→p;
        &®§nbsp;    url : "httpε§://192.168.1.77/shai​≤ zi/dice.php",  
        &nb♣±φsp;    dataType : " φ'✘jsonp",  
        ✘$ 
      ∞​>      ★∞ success : function(json){£∑÷≠  
        
 
 
var num1 = json[0];
var num2 = json[1];
diceroll(dice1,num1);//擲色子(zǐ)1動畫(huà)​÷>​
diceroll(dice2,num2);//擲色子(zǐ)2動畫( ★™™huà)
var num = parseInt(num1)+par‌‌₩✔seInt(num2);
alert(num);
$("#msg").css₽≠("top","-10px&q∑εφuot;).fadeIn(500).text(n≈↑•um+'點').animate({top:'-50px'},π&'1000').fadeOut(500);
roll(0, num); 
 
 
 
         &>;    },  
       ↑≥₽;      γφ♦≥error:function(){  
      &£α↓↑nbsp;         &nbs$&p;alert('fail');  
       "ε      }  
        & ≈₹★nbsp;}); 


後台:php
$b  =  json_encode($a©≠₽εrr_a);
$jsonp_callback=$_GET['callback'];
echo $jsonp_callback.'('.$b.' •♦♦)';


需要(yào)的(de)  隻需要(yào) &nbsπ¥p;複制(zhì)上(shàng) 改改代碼即可(k ≠£₹ě)。