0
我正在爲移動設備編寫一個Web應用程序,而且我暫時停留在一些網絡問題上。 我一直在使用Google Chrome測試軟件(& IE8),我的JSONP連接工作得很完美。 這裏是我的代碼:在android webapplication中訪問本地網絡中的.NET webservice
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);
};
當一個Android設備,這將無法工作在開始我的webapp。 Android手機與web服務位於同一網絡中。
的Stefan
[編輯31.10.2011] 問題解決了。
看來,Android 2.3的httpget方法與.NET Web方法結合存在問題。
通過添加:
$.ajaxSetup({
type: "POST"
});
我可以得到代碼工作。如果遇到同樣的問題,我希望這會有所幫助。
你應該把你的解決方案作爲答案並接受它,這樣的問題看起來並不沒有答案。其他人將能夠輕鬆看到您提出的解決方案。 –