I’m developing a PhoneGap application for Windows Phone 7 and I’m doing some jQuery AJAX calls there. Specifically, I’m sending login POST data to a remote script.
The response is in JSON when our script receive these login credentials in POST data, otherwise it returns HTML of a full login page.
I am quite sure that:
- I’ve got the domain whitelisted
- I’ve allowed cross-domain requests using $.support.cors = true and $.mobile.allowCrossDomainPages = true
- it is not an issue with setting cache: false (already played around with it)
- passing data as JSON object doesn’t work either
- playing around with contentType values did not help
When I try POST method, however there are no post data being transferred to the actual script.
I have found an old similar problem which was linked to a desktop Internet Explorer. In my case, however I’m not able to post data at all – not on 1st try, not on 2nd or any other subsequent try.
$.ajax({
url: "http://www.mypage.com/",
type: "post",
data: "login="+$('#login').val()+"&pw="+$('#pw').val(),
dataType: "json",
cache: false,
success: function(loginReturn, status, request) {
// all ok - we never get here on Windows Phone 7
}
});
Phonegap for Windows Phone jQuery ajax callback not executed
and
http://shareourideas.com/2012/03/04/phonegap-and-jquery-ajax-call-post-in-windows-phone/