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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:58:17+00:00 2026-05-12T07:58:17+00:00

Ok, I need to use ajax for some fancy pop-ups and validation things but

  • 0

Ok,

I need to use ajax for some fancy pop-ups and validation things but I want to avoid javascript redirect if everything is ok in form.

Here is the basic-simple scenario.

We have dynamic site and some user login form. Al logic (does user exist, is password ok etc) is on a server side.

Server pseudo code look like this:

$username,$password; //form user input

if (authenicate($user,$password)){
   redirect('myaccount');
}
else {
   print 'Wrong username and/or password'; //this should be displayed in the popup.
}

Now if I use ajax to display what server printed, how to tell to frontend to leave redirections to server side!?

I solved this on stupid way (because I have about 15 different forms). And I use javascript redirect if answer form server is for example “LOGGED”.

Just to mention that I use jQuery and this plugin http://malsup.com/jquery/form/.
Some sample code is here:
http://pastie.org/584993

I believe that u will understand what I need and I appriciate all suggestions and answers 🙂
Thanks!

  • 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-12T07:58:17+00:00Added an answer on May 12, 2026 at 7:58 am

    Send back JSON to the client. Have a Status parameter, a Message parameter, and a Url parameter. On success set Status to true, and the Url to the page to which to direct. On error, set status to False and the Message to the error message. On the client side, use the Status to determine whether to redirect or popup the message

     $.ajax({
         url: '/login.php',
         dataType: 'json',
         data: $('form').serialize(),
         type: 'post',
         success: function(data) {
             if (data.Status) {
                location.href = data.Url;
             }
             else {
                alert( data.Message );
             }
         }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to use some AJAX calls, we use often some input type=hidden. But
While debugging jQuery apps that use AJAX, I often have the need to see
I need to use YQL (Yahoo Query Language) to perform a cross domain ajax
I've made an application that makes full use of ajax, and what I need
I am creating some plugins that use ajax to fetch the information for the
I use JQuery AJAX to retrieve some data (title and description). As you can
I have an array of strings in Javascript that I need to use to
I'm working on a Facebook iFrame App and i need to use ajax request
I'm working on a Facebook iFrame App and i need to use ajax request
I'm not so familiar with Ajax but I keep hearing Json mentioned as some

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.