Wednesday 1 November 2017

android - Can't access php file from other domain

itemprop="text">

I written a android mobile application
in JQuery Mobile and PhoneGap in Eclipse. In the application I am calling a jquery ajax
to load list of data from other domain.



My
jquery ajax call code
is:




$.ajax({
type:
"POST",
url: WEBSERVICE_URL,
async: false,
data:
dataString,
dataType: 'json',
crossDomain: true,

success: function(data) {
loginData = new Object(data);

hideActivityIndigator();
if(loginData.success == "true"){

$.mobile.changePage("#selectionScreen", "slide", false, true);
} else
{
$("#message_ajax").html("Invalid UserName/Password.");

}
},
error: function(xhr, ajaxOptions, thrownError){

alert(xhr.status);
alert(thrownError);

hideActivityIndigator();
}

});


The variable "WEBSERVICE_URL"
has a other domain php service url.
On executing above code on "pageview"
event I am getting following error



Error:
NETWORK_ERR: XMLHttpRequest Exception 101


Any
solution is there to access service from other domain in JQuery Mobile +
PhoneGap...?


itemprop="text">
class="normal">Answer



If you are
using Phonegap/Cordova you should be able to call cross-domain web-services.. are you
using an emulator or a phone?



As for emulator I
would recommend Ripple, you can add it as a href="https://chrome.google.com/webstore/detail/geelfhphabnejjhdalkjhgipohgpdnoc"
rel="nofollow">Chrome extension or Download the href="https://bdsc.webapps.blackberry.com/html5/download/ripple"
rel="nofollow">standalone version



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...