I am making a jQuery Mobile and PhoneGap app. I need to submit a form. I made something like this:
$.ajax(
{
url: 'http://ip.ip.ip.ip:8070/services/rest/operator/login',//?email=' + email + '&password=' + haslo,
dataType: 'jsonp',
type: 'GET',
callback: 'jsonpCallback',
jsonpCallback: 'jsonpCallback',
jsonp: '_jsonp',
data: ({'email' : email, 'password' : pass}),
contentType: 'application/x-www-form-urlencoded',
success: function (data) {
window.location = ('file:///android_asset/www/custom/main.html');
},
error: function (data) {
alert('Login i/lub hasło nieprawidłowe '+data);
}
});
It works on Chrome but doesn't on my Android device. I read the documentation of both PhoneGap and jQuery Mobile, and I tried whitelisting, $.mobile.allowCrossDomainPages and $.support.cors. As I know that PhoneGap allows cross-domain I also tried to change datatype to json.
Unfortunately I have no access to server-side code. I just have this short "wadl". Web service returns 200 success or 401 access denied.
<resource path="/operator">
<resource path="/login">
<method name="GET">
<request>
<representation mediaType="application/x-www-form-urlencoded">
<param name="email" style="query" type="xs:string"/>
<param name="password" style="query" type="xs:string"/>
</representation>
</request>
<response>
<representation mediaType="application/octet-stream"/>
</response>
What am I missing?
Note: Only once I received [object Object] error message. But I have no idea how:)
Quentin was right. It was a server-side problem. When using JSONP reqests, server has to provide a response in json format, not only status code. It was enough to add true and false (properly json formatted) as a response.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.