简体   繁体   English

表单未使用jquery提交

[英]Form not submitted using jquery

I have following form, 我有以下表格,

<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>

and I'm trying submit this using following jquery code, 我正在尝试使用以下jquery代码提交此内容,

$(document).ready(function() {
    $("#offer1").click(function() {
        $("#offer1Form").submit();
        //document.getElementById("offer1Form").submit();
        alert('something');
    });
});

alert displayed, but form is not submitted. 警报显示,但表单未提交。 Please tell me the reason about this issue. 请告诉我这个问题的原因。

If you need to see the alert use below code and try. 如果您需要在代码下方查看alert ,请尝试。

$( "#offer1Form" ).submit(function( event ) {
  alert('something');
  event.preventDefault();
});

Your code works fine for me. 你的代码对我来说很好。 you can check with this 你可以检查一下

$(document).ready(function() {
    $("#offer1").click(function(event) {
        event.preventDefault();
        $("#offer1Form").submit();
        //document.getElementById("offer1Form").submit();
        alert('something');
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM