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

  • Home
  • SEARCH
  • 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 7629671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:53:41+00:00 2026-05-31T05:53:41+00:00

I have an Ajax script that allows me to check a form without refreshing

  • 0

I have an Ajax script that allows me to check a form without refreshing the page. But i want it to check if fields haven’t been complete, but if al fields are complete i want to send the user to a new page.

I’m not sure how i can do this. Here is the Ajax script:

function pass() 
{

// Real Browsers (chrome)

if (window.XMLHttpRequest) 
{
    xhr = new XMLHttpRequest();
}

// IE

else if (window.ActiveXObject) 
{
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
}

//Store data
var email = document.getElementById('email').value;
var firstname = document.getElementById('firstname').value;
var surname = document.getElementById('surname').value;
var address1 = document.getElementById('address1').value;
var address2 = document.getElementById('address2').value;
var postcode = document.getElementById('postcode').value;

//Open POST location
xhr.open("POST","addUserSeminar.php");

xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

//Make object to store all data
var obj = {email: email, firstname: firstname, surname: surname, address1: address1, address2: address2, postcode: postcode};

//Encode the data with JSON and send it to the server
xhr.send("data=" + JSON.stringify(obj));

//Check return state and change "myDiv"
xhr.onreadystatechange=function() 
{

    if (xhr.readyState==4) 
    {
        document.getElementById("settingsDiv").innerHTML = xhr.responseText;
    }

}

//Return false so form doesn't submit
return false;
}

It sends the data out to a php file where i check if the boxes are filled, if not i each a message like “Name not found”. But if all data is posted then i add a record to my database and then return true.

How could i pick up that return in my Ajax script so i can test if its true, if so forward to a new page.

Thanks for the time.

  • 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-31T05:53:43+00:00Added an answer on May 31, 2026 at 5:53 am

    return the string “TRUE” from server side on success

    PHP CODE

    if($valid_inputs) { // all input fields are valid
       echo "TRUE";
    } else {
       echo "FALSE";
    }
    

    client side JS code

    if (xhr.readyState==4) 
    {
        if (xhr.responseText.indexOf("TRUE") > -1) {
          window.location = "redirecturl.php"; //redirect url
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the minute I have a page with an AJAX script that searches a
I have a little script that allows my users to receive new items without
I have this script that I found which allows me to have userside Ajax
I have a multi-form app that gathers some information via AJAX and then allows
I have a php script that gets called via an ajax call. Values are
I have a web service site that is restful enabled, so other websites/ajax script
I have a jquery-ajax function that sends data to a php script and the
I have an application that posts data to a php script through jquery's ajax
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
I have the following Javascript libraries loaded for my page. <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js></script> <script

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.