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 9122367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:05:16+00:00 2026-06-17T06:05:16+00:00

I am implementing a login system in php and using ajax requests. this is

  • 0

I am implementing a login system in php and using ajax requests.

this is my request

hr.open("POST", url, true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

hr.onreadystatechange = function() {

    var return_data = hr.responseText;
    if(hr.readyState == 4 && hr.status == 200) {
        alert('is logged');
    }else if (hr.status == 400){
        alert('is not logged');
    }
}


hr.send(vars); // Actually execute the request

but when i get the response back the browser launches various alerts. Can anyone help how to fix this?

  • 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-06-17T06:05:18+00:00Added an answer on June 17, 2026 at 6:05 am

    Yeah its working as it should…….onreadystatechange may be called several times in one request..
    And for alerting both the conditions is that whenever the request is okay that is 200.

    It alerts :

    ‘its not logged’

    and when it got readystate=4 as well as Ok signal it alerts:

    logged in.

    Then

    readyState =4 –> request finished and response is ready

    status= 200 –> it means the request is successfully handled by the Server.

    So, 2nd alert popup because at least your request was successfully handled.
    For more info:
    https://www.w3schools.com/js/js_ajax_http_response.asp

    Here it is:

    
         xhrobj.onreadystatechange = function()
        {
          if (xhrobj.readyState == 4 && xhrobj.status == 200)
          {
            if (xhrobj.responseText)
             {
                    //put your code here 
               document.write(xhrobj.responseText);
              }
           }
         };
    

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

Sidebar

Related Questions

implementing publishActivity in PHP using the REST API using this code: $activity = array(
I'm implementing a login system. LoginViewController handles the View (duh!) for this system, LoginSession
I'm implementing a system login which in database I have this table: cat_clients Id
I'm thinking about a good solution for implementing a sign up/login system that works
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
I'm implementing a Announcement system that is loosely based on this article: https://web.archive.org/web/20211020111733/https://www.4guysfromrolla.com/articles/110409-1.aspx One
I'm having a little trouble implementing a login system that both allows users to
I have been thinking of implementing a PHP messaging system on my site. Would
I'm a beginner in PHP trying implementing a simple registration system for a website.
I'm implementing a login/authentication system for my little server-client program. I'm wondering how to

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.