本篇文章為大家展示了LARAVEL AJAX簡單跨域的示例分析,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、成都小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了九江免費(fèi)建站歡迎大家使用!
//前端
<script type="text/javascript">
function jsonpCallback(result) {
console.log('x');
console.log(result);
// for(var i in result) {
// console.log(i+":"+result[i]);//循環(huán)輸出a:1,b:2,etc.
// }
}
var JSONP=document.createElement("script");
JSONP.type="text/javascript";
// JSONP.src="https://crossdomain.com/services.php?callback=jsonpCallback";
JSONP.src="https://restapi.amap.com/v3/geocode/regeo?&key=90a7947c6e49a6e07db07d5538e79889&extensions=all&location=114.731674,30.534097&callback=jsonpCallback";
//https://restapi.amap.com/v3/geocode/regeo?&key=90a7947c6e49a6e07db07d5538e79889&extensions=all&location='.$lng.','.$lat;
document.getElementsByTagName("head")[0].appendChild(JSONP);
$.ajax({
type:'GET',
url:'https://restapi.amap.com/v3/geocode/regeo?&key=90a7947c6e49a6e07db07d5538e79889&extensions=all&location=114.731674,30.534097',
dataType:'jsonp',
success:function(res){
if(res.status == 1){
console.log(res.info);
}else{
console.log('xx');
}
}
});
$.ajax({
type:'GET',
url:'http://gps.whrango.cc',
dataType:'jsonp',
success:function(res){
if(res.status == 200){
console.log(res);
console.log('xxxxx');
}else{
console.log('xx');
}
}
});
</script>
//服務(wù)端
$maps['status']='200';
$maps['map']=$map;
// dd('dd');
return response($callback.'('.json_encode($maps).')');
上述內(nèi)容就是LARAVEL AJAX簡單跨域的示例分析,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
標(biāo)題名稱:LARAVELAJAX簡單跨域的示例分析
網(wǎng)站鏈接:http://aaarwkj.com/article42/ihphec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、App開發(fā)、做網(wǎng)站、關(guān)鍵詞優(yōu)化、電子商務(wù)、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)