提交表单后JQuery发送post请求?

你好朋友这是我的代码表单提交然后发送post链接但表单提交成功后不发送post链接。

document.getElementById("pitch_image_path_form").submit(function(e){ $.post("submit_investorform.php",{'flage':'getallimagesfromselectedid','form':'pitch_image_path_form'},function(result){ $("#pitch_image_path_showalldatafromid").html(result); }); e.preventDefault(); }); 

这是我的代码表单提交但邮件请求不发送。

亲爱的renishkhunt请尝试此代码。 这对我来说是完全有用的。

  $("#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); }); } }); 

请检查此链接这是教程。

 http://malsup.com/jquery/form/ 

.submit()是一个jQuery函数,所以你需要在jQuery包装器中包装$("#pitch_image_path_form")[0] ,如下所示:

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

在DOM中没有submit()事件,你正在混合DOM和jQuery

更改

 document.getElementById("pitch_image_path_form").submit 

 $("#pitch_image_path_form").submit 
 $("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); } ); 

});

因为DOM不支持submit(),所以在DOM中有commit()函数。 当你最后一次问这个时,答案是一样的。

当您调用.submit() ,它会使用

的指定操作发布

您可能希望通过使用event.stopPropagation();来停止传播event.stopPropagation();event.preventDefault(); 或者return false; 在你的function结束时。

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

另外,正如epascarello所指出的, .submit()是一个jQuery函数。

如果你想使用它,通过在submit()之前删除[0]在jQuery对象上使用它, 因为你不应该有多个具有相同ID的元素