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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:28:34+00:00 2026-06-11T05:28:34+00:00

I am using jQuery 1.7.2 version and I am submitting my form using Ajax

  • 0

I am using jQuery 1.7.2 version and I am submitting my form using Ajax like that

$("input#addPostSubmit").click( function(){
    $.ajax({
            //this is the php file that processes the data and send mail
            url: BASE_URL+"post/ajaxcreate",    
            //POST method is used
            type: "POST",
            //pass the data         
            data: $("#addImage").serialize(),       
            //Do not cache the page
            cache: false,
            //success
            success: function (html) {
                         var obj = jQuery.parseJSON(html);          
                    if(obj.Status == 'Success'){
                        $("#error").removeClass('hide');
                        $("#error").addClass('success');
                        $("#error").html(obj.Message);
                        $.fn.colorbox.resize();
                        setTimeout(function(){$.fn.colorbox.close()},5000);
                        window.parent.location.reload();    
                    }
                    if(obj.Status == 'Fail'){
                        $('.add_post_submit').html('<input type="button" id="addPostSubmit" value="Create" />');
                        $("input#addPostSubmit").removeAttr('disabled');
                        $("#error").removeClass('hide');
                        $("#error").addClass('error');
                        error = obj.Message.split(';');
                        html = '<ul>';
                        for(a=0;a<error.length;a++){
                            html += '<li>'+error[a]+'</li>';
                        }
                        html += '</ul>';    
                        $("#error").html(html);
                        $('html').css({overflow: 'hidden'});
                        $.fn.colorbox.resize();
                    }
            }       
    });
}); 

For example, null is not allowed on one of the form field. When server validate form and returns errors I show it, when I again click the button it not worked.

It is working fine but the problem is when ajax request is completed and server returns any form error then submit button did not work.

  • 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-11T05:28:35+00:00Added an answer on June 11, 2026 at 5:28 am

    i’d recommend listening to the submit event on the document, instead of the click handler.

    $(document).on('submit','form',function(e){
      e.preventDefault();
      $.ajax({
              //this is the php file that processes the data and send mail
              url: BASE_URL+"post/ajaxcreate",    
              //POST method is used
              type: "POST",
              //pass the data         
              data: $("#addImage").serialize(),       
              //Do not cache the page
              cache: false,
              //success
              success: function (html) {
                  // come code
              }       
      });
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery on() version 1.7. I bind my events usually like this: $(.foo).on(click, function()
I am using jQuery (version 1.8.1) with PHP (version 5.3) to submit a form
ok, im using Jquery (edge) version, and bootstrap 2.0, and i have this code:
I'm using XAMPP Lite - USB Version and found that the jQuery chained select
I am using jquery validate and the jquery version of tinymce. I found this
I am using jQuery (version 1.6.2) to generate an animation that works well on
I'm trying to create a couple of buttons using jQuery, with commands like this:
I'm trying to handle a php mailform with ajax. It's a simple form that
This simple script, to add / delete tablerows using jQuery works well with version
I am using jquery fancybox version 2.0.3. I want to prevent close on click

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.