I am writing a Webapplication for a mobile device and I'm currenty stuck with some network issues.
I've been testing the software in Google Chrome (& IE8) and my JSONP connection works just perfect.
Here is my Code:
function GetJSON() {
var cbSuccess = false;
$.ajax('http://10.221.5.132:1234/WcfService1/WcfTestService/TimeInfo.json/Test?method=?', {
crossDomain: true,
dataType: "jsonp",
success: function (data, text, xhqr) {
var myObj = $.parseJSON(data);
alert(myObj.data);
cbSuccess = true
},
error: function (jqXHR, textStatus, errorThrown) {
$('#ausgabe').html('Error: ' + textStatus + ' - ' + errorThrown); alert("Error");
cbSuccess = true;
}
}
);
setTimeout(function() {
if (!cbSuccess) { alert("connection failed"); }
}, 5000);
};
アンドロイドデバイスでWebappを起動すると、これは機能しません。 Android PhoneはWebサービスと同じネットワーク内にあります。
ステファン
[編集:31.10.2011]
問題が解決しました。
Android 2.3と.NET Webメソッドを組み合わせたhttpgetメソッドに問題があるようです。
追加することによって:
$.ajaxSetup({
type: "POST"
});
私はコードを動作させることができます。同じ問題に遭遇しているなら、これが助けてくれることを願っています。