JQuery send post request after submit form?

后端 未结 6 2058
无人及你
无人及你 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:13

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

    .

    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.

提交回复
热议问题