Simple ajax function providing difficult debug situation in Chrome/Safari

Simple ajax function providing difficult debug situation in Chrome/Safari

 Hi,

I have a *very* simple jQuery/ajax script for a membership driven website.  The script just checks to see if the user entered info, validates it against my database and returns 1 for a failed login attempt, and 0 if the username/password match.

The function works perfectly when I run it w/o calling it from ajax.  


**Firefox:** everything works.  

**Chrome/Safari:** The query is locking everything up.  When I enter valid info, there isn't even any record of a request going out (in the developer tools chrome/safari supply).  When invalid info is entered the request is going out and it returns 3.


I'm pretty baffled by this.


Is it a "sandbox" issue?  as I understand it Firefox and Chrome/safari handle XHR differently... Although don't ask me how.


I am running a base install of MAMP .  Could this be something on my developer environment?  (I will be testing it on a live server later this afternoon)

Here is my AJAX call and the php script it is calling.

AJAX:

  
  1.  $.ajax({
  2.       //I've also tried..
  3.       //url: '_modules/php/session.php',
  4.      url: 'http://localhost/current/100TradeJack/httpdocs/_modules/php/session.php',
  5.      type: 'POST',
  6.      cache: false,
  7.      timeout: 5000,
  8.      data: "method=login&"+$('#loginTop').serialize(),
  9.      error: function(XMLHttpRequest, ajaxOptions, thrownError)
  10.      {
  11.       alert("ERORR!!");
  12.      },
  13.      success: function(response){
  14.       alert(response);
  15.       if(response == '0'){ 
  16.        alert("log user in");
  17.        window.location.replace("http://localhost/current/100TradeJack/httpdocs/trading.php");
  18.       } else if(response == '1') {
  19.        alert("invalid username/password");
  20.       } else {
  21.        alert("ERRROOR!");
  22.       }
  23.       
  24.      }
  25.     });

session.php

  
  1.  $connection = mysql_connect("localhost","root","root") or die(mysql_error());
  2.     mysql_select_db("sandbox_members", $connection) or die(mysql_error());
  3.     
  4.     
  5.     if($email){
  6.      $email = mysql_real_escape_string($email);
  7.     } else {
  8.      return 1;
  9.     }
  10.     
  11.     if($password){
  12.      $password = mysql_real_escape_string($password);
  13.     } else {
  14.      return 1;
  15.     }
  16.     
  17.      
  18.     $query = "SELECT * FROM users WHERE username='". $email . "' AND password='". $password ."'";
  19.     
  20.     $result = mysql_query($query);
  21.     
  22.     if($row = mysql_fetch_array($result)){
  23.      return 0; 
  24.     } else {
  25.      return 3;
  26.     }
  27.     
  28.     //if it gets to here the username/password combo was incorrect or was not found in the db
  29.     return 1;
  30.     mysql_close($connection);