Form Submission not working second time after submiting using Jquery and Ajax

Saurabh

I have made a PHP page that submits data internally using AJAX and Jquery. It works fine, but after submit when I click on submit again(second time) it does not happen.. Here is the code for reference

$(function(){
    $('#sub').click(function(){
        $('#myForm').on('submit',function(e){
            e.preventDefault();
            $.ajax({
                url:"file.php",
                type:'POST',
                data:new FormData(this),
                contentType: false,
                processData:false,
                success:function(data){
                    $("#myResponse").replaceWith(data);}
                });
            });
        });
    });
});

This is the submit button inside from

<input type="submit" value="Submit" name="submit" id="sub" onclick="submitForm('file.php')" data-toggle="modal" data-target="#myModal">
Taniya

Remove the (onclick="submitForm('file.php')") from the input type. And also remove "$('#sub').click(function(){});" . only keep it like:

  $('#myForm').on('submit',function(e){
   e.preventDefault();
   $.ajax({
   url:"file.php",
   type:'POST',
  data:new FormData(this),
  contentType: false,
  processData:false,
  success:function(data){
  $("#myResponse").replaceWith(data);}
    });
   });
  });

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Don't reload page after form submission using ajax and jquery

From Dev

Submiting Form using Jquery and Ajax without action attribute

From Dev

Why does the second form disappear after submiting?

From Dev

Basic form submission with jquery/ajax not working

From Dev

Ajax form submission with Jquery validation plugin is not working

From Dev

Ajax form submission on a form created using jquery

From Dev

Form submit not working after second attempt in jQuery AJAX

From Dev

Form submit not working after second attempt in jQuery AJAX

From Dev

Javascript php validation, form submiting on the second time submit after filling one text box out of 2 textboxes

From Dev

Form submission using ajax and page view moderation after the submission

From Dev

Modal form Submission to PHP using Jquery .ajax

From Dev

why is my form not submiting using ajax

From Dev

Jquery form submission is not working

From Dev

Submiting a form with jquery/AJAX isn't working when clicking the submit button

From Dev

Bootstrap dropdown not working after initial ajax form submission

From Dev

jQuery ajax form submission to php not working with response from server

From Dev

wordpress ajax form submission is not working?

From Dev

Auto form Submission not working Ajax

From Dev

wordpress ajax form submission is not working?

From Dev

How do i hide a form after submission is succesfull with Ajax/Jquery

From Dev

jquery ajax requests are not responding on the new tab after the php form submission

From Dev

after second ajax call jquery not working

From Dev

after second ajax call jquery not working

From Dev

Redirect after AJAX form submission

From Dev

Redirect after AJAX form submission

From Dev

JQuery/PHP form not Submiting

From Dev

Listener for form submission not working with jQuery

From Dev

Submiting a form using PHP

From Dev

Submiting form using javascript

Related Related

  1. 1

    Don't reload page after form submission using ajax and jquery

  2. 2

    Submiting Form using Jquery and Ajax without action attribute

  3. 3

    Why does the second form disappear after submiting?

  4. 4

    Basic form submission with jquery/ajax not working

  5. 5

    Ajax form submission with Jquery validation plugin is not working

  6. 6

    Ajax form submission on a form created using jquery

  7. 7

    Form submit not working after second attempt in jQuery AJAX

  8. 8

    Form submit not working after second attempt in jQuery AJAX

  9. 9

    Javascript php validation, form submiting on the second time submit after filling one text box out of 2 textboxes

  10. 10

    Form submission using ajax and page view moderation after the submission

  11. 11

    Modal form Submission to PHP using Jquery .ajax

  12. 12

    why is my form not submiting using ajax

  13. 13

    Jquery form submission is not working

  14. 14

    Submiting a form with jquery/AJAX isn't working when clicking the submit button

  15. 15

    Bootstrap dropdown not working after initial ajax form submission

  16. 16

    jQuery ajax form submission to php not working with response from server

  17. 17

    wordpress ajax form submission is not working?

  18. 18

    Auto form Submission not working Ajax

  19. 19

    wordpress ajax form submission is not working?

  20. 20

    How do i hide a form after submission is succesfull with Ajax/Jquery

  21. 21

    jquery ajax requests are not responding on the new tab after the php form submission

  22. 22

    after second ajax call jquery not working

  23. 23

    after second ajax call jquery not working

  24. 24

    Redirect after AJAX form submission

  25. 25

    Redirect after AJAX form submission

  26. 26

    JQuery/PHP form not Submiting

  27. 27

    Listener for form submission not working with jQuery

  28. 28

    Submiting a form using PHP

  29. 29

    Submiting form using javascript

HotTag

Archive