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);
};
When starting my Webapp on an android device this will not work. The Android Phone is inside the same network as the webservice.
Stefan
[Edit 31.10.2011]
Problem Solved.
It appears, that there is a problem with the httpget method with Android 2.3 in combination with the .NET web methods.
By adding:
$.ajaxSetup({
type: "POST"
});
I can get the code to work. I hope this helps, if you’re encountering the same problems.
It appears, that there is a problem with the httpget method with Android 2.3 in combination with the .NET web methods.
By adding:
i can get the code to work. I hope this helps, if you’re encountering the same problems.