I'm trying to get some data through a PHP file in AJAX. It works
really fine, but only on Desktop. When i go mobile (iPhone 4, Android)
it doesnt work. I've got a status = 0 back and my responseText is
empty.
It goes about the following code (with a callback).
Code:
function loadXML(method, url, onsuccess)
{
var xmlhttp;
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{ // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
onsuccess(xmlhttp.responseText);
}
if(xmlhttp.readyState == 4 && xmlhttp.status == 0)
{
onsuccess(xmlhttp.responseText);
}
}
xmlhttp.open(method, url, true);
xmlhttp.send(null);
}
function initialize() {
loadXML("GET", "http://example.com/testing.php",
function(location) {
//Here is the variabele
location empty (only on Android/iPhone).
});
}
When i test my script on a browser, it gives me the right data back.
On Android/iPhone, it gives nothing back. Knows anybody the problem
and how i can solved it?
There something wrong within this part. There's a mess:
Code:
function initialize() {
loadXML("GET", "http://example.com/testing.php",
function(location) {
//Here is the variabele
location empty (only on Android/iPhone).
});
}
It is not very clear where the functions start and end...
OK. The reason is simple: servers do often presume that a request to an absolute URL is a request to another domain, which is impossible without using a third, server-side, code (a proxy). the response status=0 usually cover that case.
would u plz specify wat relative link means?
i have specified the url as http://ip addressortno/the web service name
the web service is located on anoder machine so i have to specify the ip address
Bookmarks