Ajax not working on iphone. how do i get error message?

Hello. my ajax scripts work both on my laptop and on my android phone but not on my iphone. instead of going to success it goes to error.

the error doesnt give me much info so i wonder if i can get more info in any way?

XMLHttpRequest = [object Object]
JSON.stringify(XMLHttpRequest) = readystate: 0, status: 0, statustext: error
textStatus =
errorThrown = error

I have tried with both minified and uncompressed jquery.
I have tried with adding

$(document).ready(function(){
	$.ajaxSetup({ cache: false }); 
});

and

cache: false,
headers: { "cache-control": "no-cache" },

but nothing have worked yet

check the server logs for a connection request

Where do i find that in Ubuntu, apache?
I looked into /var/log/apache2/error.log but it didnt tell me anything

/var/log/ apache2/access

possibly

/var/log/apache2/error.log didnt give me any info about it

That’s the error log, you want access logs.

/var/log/apache2/access.log is empty

Okay, so nothing is being logged. Have you tried to output the returned error the that request is returning?

How do i do that?

This is the code

$.ajax({
        type: "POST",
        url: "visitor_settings.php",
        datatype: "json",
        data: {
            test: JSON.stringify(p),
        },
        success: function(e) {
            
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
           alert(JSON.stringify(XMLHttpRequest) + "+" + textStatus + "+" + errorThrown);
        }
    })
err = JSON.parse(XMLHttpRequest.responseText);
alert(err.Message);

When replacing that with my alert, no alert is being shown what so ever but the ajax request still doesnt seem to work. now the access.log have logged info tho. give me a second

at least something is being logged.

yea. i couldnt really see anything in the access logs

I found the problem.

When setting the cookie like this it doesnt work on iphone but on android and desktop

setcookie('visitor', $hash, time() + (2592000 * 30), "localhost");

so i had to set it like this to make it work

setcookie('visitor', $hash, time() + (2592000 * 30), "/");

took me way to many hours to figure out…

I’d like to point out, you never mentioned you were using cookies.

Sponsor our Newsletter | Privacy Policy | Terms of Service