使用jsonp完美解決跨域問題

字號(hào):


    調(diào)用web接口,get請求,發(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請求參數(shù)dataType:'JSONP'。
    代碼如下:
    $.ajax({
    url: "http://.......",
    type: 'GET',
    dataType: 'JSONP',//here
    success: function (data) {
    }
    });
    哎這真是難者不會(huì),會(huì)者不難啊,簡單的一行代碼,就解決了這個(gè)大問題。。。??迆