Javascript 未使用jquery提交表单
我有以下表格Javascript 未使用jquery提交表单,javascript,jquery,html,forms,Javascript,Jquery,Html,Forms,我有以下表格 <form method="post" action="test.php" id="offer1Form"> <input type="hidden" name="c" value="3883316"> <input type="hidden" name="qtyadd" id="qtyadd" value="1"> <input type="hidden" name="buyid" id="buyid" value
<form method="post" action="test.php" id="offer1Form">
<input type="hidden" name="c" value="3883316">
<input type="hidden" name="qtyadd" id="qtyadd" value="1">
<input type="hidden" name="buyid" id="buyid" value="multi">
<input type="hidden" name="multi" id="multi" value="11,1;150,1;182,1;27,1; ">
<input type="hidden" name="promocode" value="<?php echo $promote_code1?>">
<input type="hidden" name="continue" value="<?php echo " http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI] "; ?>" />
<map name="map">
<area id="offer1" shape="rect" coords="657, 515, 913, 557" href="" />
</map>
</form>
显示警报,但未提交表单。请告诉我此问题的原因。如果您需要查看
警报
请使用下面的代码并重试
$( "#offer1Form" ).submit(function( event ) {
alert('something');
event.preventDefault();
});
你的代码对我来说很好。 你可以看看这个
$(document).ready(function() {
$("#offer1").click(function(event) {
event.preventDefault();
$("#offer1Form").submit();
//document.getElementById("offer1Form").submit();
alert('something');
});
});
那么
document.getElementById(“offerForm”).submit()呢
一个可能的原因是有一个名为preventDefault()
的提交事件处理程序,您将看不到警报
,因为表单
已提交,页面被重定向没有显示警报,但显示警报后页面刚刚刷新
$(document).ready(function() {
$("#offer1").click(function(event) {
event.preventDefault();
$("#offer1Form").submit();
//document.getElementById("offer1Form").submit();
alert('something');
});
});