3

I can't for the life of me figure out why this is happening.

This is kind of a repost (submitted to stackoverflow, but maybe a server issue?).

I am running a javascript log out function called logOut() that has make a jQuery ajax call to a php script...

function logOut(){
    var data = new Object;
    data.log_out = true;
    $.ajax({
        type: 'POST',
        url: 'http://www.mydomain.com/functions.php', 
        data: data,
        success: function() {
             alert('done');
        }
    });
}

the php function it calls is here:

if(isset($_POST['log_out'])){ 
    $query = "INSERT INTO `token_manager` (`ip_address`) VALUES('logOutSuccess')"; 
    $connection->runQuery($query); // <-- my own database class...
    // omitted code that clears session etc...
    die();
}

Now, 18 hours out of the day this works, but for some reason, every once in a while, the POST data will not trigger my query. (this will last about an hour or so). I figured out the post data is not being set by adding this at the end of my script...

$query = "INSERT INTO `token_manager` (`ip_address`) VALUES('POST FAIL')"; 
$connection->runQuery($query);

So, now I know for certain my log out function is being skipped because in my database is the following data:

alt text

if it were NOT being skipped, my data would show up like this:

alt text

I know it is being skipped for two reasons, one the die() at the end of my first function, and two, if it were a success a "logOutSuccess" would be registered in the table.

Any thoughts? One friend says it's a janky hosting company (hostgator.com). I personally like them because they are cheap and I'm a fan of cpanel. But, if that's the case???

Thanks in advance.

-J

4
  • CPanel is the choice of just about every shared web host provider on the planet, so if "cheap" and "cpanel" are your criteria, then there are dozens and dozens of hosts you could choose from, so it could be worth a shot. May 19, 2010 at 22:37
  • @Farseeker... I haven't been around the web game THAT long, but I feel like every client I get has a different control panel on a different host. It ends up taking me 20 minutes just to edit a database because I have to track down myphpadmin.
    – Jascha
    May 20, 2010 at 5:01
  • cpanel has a lot of different skins and a lot of hosts choose (I feel) rediculous ones, but then again maybe we've been looking in different places. I agree with you though, cpanel is my favourite. May 20, 2010 at 5:15
  • Can you give us firebug's output when you POST your request? Jul 9, 2010 at 7:27

2 Answers 2

1

Is that the only script that calls functions.php?

Instead of logging just "POST FAIL", try logging the result of print_r($_POST, true) and maybe $_SERVER['HTTP_REFERER']. That may tell you where the failed calls are coming from.

0

Try an HTTP sniffer to first figure out if it's your PHP script with the problem or the AJAX code. Or it could be a client-side condition you're not aware of. It might not be your AJAX code at all. Sniffer will help eliminate whether it's definitely a client-side issue or not.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .