2012-05-14 18 views
3

我試圖製作一個適用於所有桌面瀏覽器但不適用於iPhone和Android的JSONP請求。Safari/iPhone和Opera/Android中的JSONP不起作用

Im做跨域調用webservice的返回一個JSONP,如:

myFunction({name : "Jonh", last : "Doe"}) 

     $.ajax({ 
       type: "GET", 
       crossDomain: true, 
       url: "http://192.168.1.41:8081/Service1/", 
       dataType: "jsonp", 
       processData : true, 
       headers: { 
        "Content-Type": "application/json" 
       }, 
       jsonp : "myFunction", 
       jsonpCallback: "myFunction" 
       }); 

    function myFunction(data) 
    { 
     alert("Hello world!"); 
    } 

它適用於桌面,但不能移動!

有什麼想法?

+2

看到這個職位的答案:http://stackoverflow.com/questions/7747264/jsonp -calls-not-working-with-apple-mobile-web-app-capable-yes – Aleksey

+0

謝謝你幫了我很多! :) –

回答

0

我的問題是,我從http服務器(我的開發機器)發送JSONP請求到https服務器。

是完全清楚它的外觀像http://localhost.comhttps://api.xxx.com

要求它工作在不同的移動Safari瀏覽器所有瀏覽器。

的http - > HTTP =工作
HTTPS - > HTTPS =工作
HTTP - > HTTPS =不起作用