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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:13:38+00:00 2026-06-04T13:13:38+00:00

I have a issue with my ajax form submission.I am dynamically submitting a form

  • 0

I have a issue with my ajax form submission.I am dynamically submitting a form and using php at the server side to process it.This is the ajax success function.

   $.ajax({
                        type: "POST",
                        url: "register.php",
                        data: "uname="+uname+"&eid="+eid+"&pwd="+pass+"&cpwd="+cpass+"&country="+coun+"&contact="+contact,
                        dataType: "html",
                        success: function(data){
                            if(data!="error")
                            {   
                               //alert(data);
                                $("#user_status", window.parent.document).html("Welcome "+data+"&nbsp;&nbsp;|&nbsp;&nbsp;<a href='forum/logout.php'>Logout</a>");
                                if(window.parent.document.getElementById('post_user_name'))
                                    $("#post_user_name", window.parent.document).html(msg);
                                parent.$.fancybox.close();
                            }
                            if(data=="error")
                            {   
                                //alert(data);
                                $("#status").html("<span><center><font class='formright err_msg' style='width:176px;'>The user is already register with us.</font><center></span>");
                                return false;
                            }

Now if the user is valid he is logged in and f not there has to be an error like “Already exists”.The valid part works fine but for invalid I return an error from the php file but still my error message doesn’t show up and just error is printed on the screen.I am using fancybox for my forms(jquery fancybox)
PHP code is

        if($_POST['pwd']==$_POST['cpwd'])
            {
                $username   = $_POST['uname'];
                $email      = $_POST['eid'];
                $password   = md5($_POST['pwd']);
                $cpassword  = $_POST['cpwd'];
                $contact_no = $_POST['contact'];
                $country    = $_POST['country'];

                $cnt      =     $checkUser['cnt'];

                if($cnt!=0) 
                {
                    echo "error";
                    //exit;
                    /*$_SESSION['error_msg']    =   'Email Address already exists';
                    redirect_to_link("index.html");*/

                } 
                else
                {
                    //echo "entered here";
                    $userArray = array();
                    //$user = return_post_value($_POST['uname']);
                    $userArray['uname'] = return_post_value($_POST['uname']);
                    $userArray['email'] = return_post_value($_POST['eid']);
                    $userArray['password'] = md5(return_post_value($_POST['pwd']));
                    $userArray['contact_no'] = return_post_value($_POST['contact']);
                    $userArray['country'] = return_post_value($_POST['country']);

                    //print_r($userArray);
                    //exit;
                    $userObj->addUserValue($userArray);
                    $_SESSION['username']=  $userArray['uname'];            
                    echo $userArray['uname'];
                                  //    return $user;
                }

The echo $userArray[‘uname’]; part works but echo “error” doesn’t.Checked in Firebug response header,i can see the error word returned.
Can anyone throw some light on it?
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-06-04T13:13:40+00:00Added an answer on June 4, 2026 at 1:13 pm

    Use this to compare if($.trim(data)!=”error”)

    And don’t recheck for if($.trim(data)==”error”)

    use

    if($.trim(data)!="error")
    {
     //
    }
    else{
    //
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login form using jquery ajax and a php code. The issue
I have implemted AJAX form submission into my webforms before without issue but now
I have a small issue on a search form. PLease check this: http://www.fortisfitness.ca/test/script.php What's
I have an issue using Ajax upload with Spring 3 MVC. I understand that
my issue is that i have two ajax calls to php for a registration
I have an issue in writing fixed width text file using php and data
I have a simple page that returns an ajax success/error message on submission. The
The issue is that at form submission through ajax the page still reloads, even
Ohey, I have a central function that runs AJAX requests throughout my order form.
I am trying to submit a form using Ajax.Updater and have the result of

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.