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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:44:44+00:00 2026-05-30T04:44:44+00:00

I am building a registration form with jquery which should handle the request via

  • 0

I am building a registration form with jquery which should handle the request via Ajax.
My code:

$.ajax( 
{ 
    type: "POST", 
    url: "http://www.example.com/register.php", 
    data: $("#register-form").serialize(),
    cache: false,
    success: function(message)
    {   
                    $("#reg_notification").html(message).fadeIn(400);               
    }           
});

Now the register.php should either output an error if for example the email address is not valid and this will be put into the div reg_notification. If no error is made, then the user should be redirected to a “welcome page”. But it is important that this page is not allways static, so in other words, I can not use a location.href in the jquery code but want to use

header("Location: http://www.example.com")

in PHP. The problem is that the user wont be redirected but the content of www.example.com will be put inside the div reg_notification.

I found a similar problem here: How to manage a redirect request after a jQuery Ajax call but the difference is that there they are using json which I can not use due to my server and they are also redirecting inside the javascript and not in the php file.

  • 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-30T04:44:45+00:00Added an answer on May 30, 2026 at 4:44 am

    Impossible with header redirection.

    Use something like that:

    ...
    success: function(message)
    {   
         $("#reg_notification").html(message)
              .fadeIn(400, function() {window.location = "url"});
    }
    

    or

    success: function(response)
    {   
         if (response.success) {
              $("#reg_notification").html(response.message)
                   .fadeIn(400, function() {window.location = response.redirectTo; } );
         } else {
              // somethings else
         }
    }   
    

    in php:

    header("Content-type: application/json");
    echo json_encode(array(
        "success" => true,
        "message" => "some message",
        "redirectTo" => "my url"
    ));
    

    UPDATE
    header redirect impossible because XMLHttpRequest transparently follows to redirect url for get result. See there

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

Sidebar

Related Questions

I am building a PHP registration form which takes the following fields for up
I'm building my first CodeIgniter app - and have a registration form. I'm using
I am building a little registration page that is going to be accessed via
In building components for installation, I know that registration units are generally a should
I am using django registration to handle um... registration on a site I'm building.
I am building a user registration form in asp.net. I want to check if
I am building a user registration form using C# with .NET. I have a
I am building a time registration program. Users can work on a project, and
I am looking at building the login/registration part of a website (ASP.NET) and would
I'm building a website that will require user registration and logon. I would like

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.