Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 565037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:49:48+00:00 2026-05-13T12:49:48+00:00

I have a very simple jQuery/ajax script for a membership driven website. The script

  • 0

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:

$.ajax({
  //I've also tried..
  //url: '_modules/php/session.php',
 url: 'http://localhost/current/100TradeJack/httpdocs/_modules/php/session.php',
 type: 'POST',
 cache: false,
 timeout: 5000,
 data: "method=login&"+$('#loginTop').serialize(),
 error: function(XMLHttpRequest, ajaxOptions, thrownError)
 {
  alert("ERORR!!");
 },
 success: function(response){
  alert(response);
  if(response == '0'){ 
   alert("log user in");
   window.location.replace("http://localhost/current/100TradeJack/httpdocs/trading.php");
  } else if(response == '1') {
   alert("invalid username/password");
  } else {
   alert("ERRROOR!");
  }

 }
});

session.php:

if($_POST['method'] == 'login'){
    $validated = login($_POST['email'], $_POST['password']);
    echo $validated;
}


function login($email, $password){
$connection = mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("sandbox_members", $connection) or die(mysql_error());


if($email){
 $email = mysql_real_escape_string($email);
} else {
 return 1;
}

if($password){
 $password = mysql_real_escape_string($password);
} else {
 return 1;
}


$query = "SELECT * FROM users WHERE username='". $email . "' AND password='". $password ."'";

$result = mysql_query($query);

if($row = mysql_fetch_array($result)){
 return 0; 
} else {
 return 3;
}

//if it gets to here the username/password combo was incorrect or was not found in the db
return 1;
mysql_close($connection);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:49:48+00:00Added an answer on May 13, 2026 at 12:49 pm

    There is a small issue in your PHP code:

    After your query db, you return some numbers representing state, however on the end of the script you close the connection to your database… mysql_close($conn) will never occur as you jump out of the function scope with those various returns before the closing statement. Maybe those hiccups you experience are because of unclosed DB connections.

    JS code looks fine

    I modified the ajax call to grab a static html, which I edited to various scenarios (using 0, 1, …) and it worked perfectly (Opera, Chrome, FF)..

    Also try window.alert($('#loginTop').serialize()) to check posted data, or create a plain html document with a form and JS (without all other logic) and point it to your script.

    Also check your scripts for console.log() as this may destroy your javascript in other browsers than FF

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 364k
  • Answers 364k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is just a plain old NSWindow. It's not textured.… May 14, 2026 at 3:42 pm
  • Editorial Team
    Editorial Team added an answer It means that regardless of what font you actually use,… May 14, 2026 at 3:42 pm
  • Editorial Team
    Editorial Team added an answer Convolution is an operation distinct from multiplication. If h[n] =… May 14, 2026 at 3:42 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.