首頁 >php教程 >php手册 >跨域名设置cookie或获取cookie

跨域名设置cookie或获取cookie

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-13 11:30:321314瀏覽

可以使用jquery里面的ajax中的jsonp的方式来访问就可以了。代码如下:

<span  1</span> <span $.ajax({
</span><span  2</span>     url: 'your url'<span ,
</span><span  3</span>     data: {'xx' : 'xx', 'xx2' : 'xx2'<span },
</span><span  4</span>     success: <span function</span><span (data){    
</span><span  5</span>         <span //</span><span 成功后执行的</span>
<span  6</span> <span     },
</span><span  7</span>     type:'GET'<span ,
</span><span  8</span>     dataType: 'jsonp',<span //</span><span 重要的是这个</span>
<span  9</span>     jsonp: "callback"<span ,
</span><span 10</span>     jsonpCallback:"jsonpReturn"
<span 11</span> });

 

php中可以这样写:

<span 1</span> <span function</span><span  login()
</span><span 2</span> <span {
</span><span 3</span>     <span return</span> 'jsonpReturn('.jsondecode(<span $array</span>).')'<span ;
</span><span 4</span> }

 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:开始yaf之旅下一篇:获取文件名后缀