Unable to post to Restful API through Ajax using android phone -
i developing android application using phonegap. trying execute simple login module, works fine in web browser. when comes apk, not working. not able post request restful api.
var usr = $('#email_address').val(); var pass = $('#password').val(); if(usr != '' && pass != ''){ alert("before calling method"); $.ajax({ url:apiurl +"api/sample/sample123", type: "post", crossdomain : true, data: {username:usr,password:pass}, datatype: "json", success: function(data){ /*here posting dummy code, can't show original code*/ var response = eval(data); alert(response.response); } });
when executing on android phone, getting first alert above i.e "before calling method" not showing alert. have configured res/xml/cordova.xml
<access uri="*" subdomains="true"/>
also have referred previous related doubts stackoverflow. didn't helped me. please me to, waiting positive response...
try one
formdata = { username: $('#email_address').val(), password: $('#password').val() } $.ajax({ url: apiurl + "api/sample/sample123", type: "post", crossdomain: true, contenttype: 'application/json', data: formdata, datatype: "json", success: function(data) { alert(data); } });
Comments
Post a Comment