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

使用jsonp完美解決跨域問題

 更新時(shí)間:2014年11月27日 09:24:24   投稿:hebedich  
在項(xiàng)目中遇到錯(cuò)誤提示“No 'Access-Control-Allow-Origin' header is present on the requested resource.”查了下度娘,這個(gè)問題和安全機(jī)制有關(guān),默認(rèn)不允許跨域調(diào)用,這里記錄一下解決方案,防止以后再犯相同的錯(cuò)誤。

調(diào)用web接口,get請(qǐng)求,發(fā)現(xiàn)提示:No 'Access-Control-Allow-Origin' header is present on the requested resource.

這個(gè)和安全機(jī)制有關(guān),默認(rèn)不允許跨域調(diào)用

處理手段:使用jsonp格式, ajax請(qǐng)求參數(shù)dataType:'JSONP'。

復(fù)制代碼 代碼如下:

$.ajax({
        url: "http://.......",
        type: 'GET',
        dataType: 'JSONP',//here
        success: function (data) {

        }
    });


哎這真是難者不會(huì),會(huì)者不難啊,簡(jiǎn)單的一行代碼,就解決了這個(gè)大問題。。。??迆

相關(guān)文章

最新評(píng)論