JQuery send post request after submit form?

后端 未结 6 2057
无人及你
无人及你 2021-01-26 09:58

Hello Friends this is my code to form submit and then send post link but form submit success then after not send post link.

document.getElementById(\"pitch_image         


        
相关标签:
6条回答
  • 2021-01-26 10:05

    dear renishkhunt please try this code. this is help fully for me.

        $("#pitch_image_path_form").ajaxSubmit({ success: function(){ 
                $.post("submit_investorform.php",{'flage':'getallimagesfromselectedid','form':'pitch_image_path_form'},function(result){
                        $("#pitch_image_path_showalldatafromid").html(result);
                    });
         } });
    

    please check this link this is tutorial.

    http://malsup.com/jquery/form/
    
    0 讨论(0)
  • 2021-01-26 10:08

    Because DOM does not support submit(), there is do submit() function in DOM. Same exact answer when you asked this the last time.

    0 讨论(0)
  • 2021-01-26 10:13

    When you call .submit(), it posts the form with the specified action of the <form>.

    You might want to stop the propagation, by using either event.stopPropagation();, event.preventDefault(); or return false; at the end of your function.

     $("#pitch_image_path_form").submit(function(event){
            event.stopPropagation(); 
            event.preventDefault();
    
            //Your .post()
    
            return false;
        });
    

    Plus, as epascarello pointed out, .submit() is a jQuery function.

    If you want to use it, use it on the jQuery object by removing [0] before submit(), as you're not supposed to have multiple elements with the same ID.

    0 讨论(0)
  • 2021-01-26 10:14

    .submit() is a jQuery function, so you need to wrap your $("#pitch_image_path_form")[0] in a jQuery wrapper, like so:

    $($("#pitch_image_path_form")[0]).submit(function(){

    0 讨论(0)
  • 2021-01-26 10:19
    $("pitch_image_path_form").submit(function(e){
    e.preventDefault();
    $.post(
        "submit_investorform.php",
        {'flage':'getallimagesfromselectedid','form':'pitch_image_path_form'}
        , function(result) { $("#pitch_image_path_showalldatafromid").html(result); }
    );
    

    });

    0 讨论(0)
  • 2021-01-26 10:27

    There is no submit() event in DOM, you are mixing DOM and jQuery

    change

    document.getElementById("pitch_image_path_form").submit
    

    to

    $("#pitch_image_path_form").submit
    
    0 讨论(0)
提交回复
热议问题