1

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,

$(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.

4
  • what about document.getElementById("offer1Form").submit(); Commented Jun 23, 2015 at 10:22
  • One possibe reason is there is a submit event handler which is called preventDefault() Commented Jun 23, 2015 at 10:23
  • You won't see alert because form is submitted and page is redirected Commented Jun 23, 2015 at 10:24
  • 1
    No alert is displayed but page is just refreshed after showing alert Commented Jun 23, 2015 at 10:27

2 Answers 2

2

If you need to see the alert use below code and try.

$( "#offer1Form" ).submit(function( event ) {
  alert('something');
  event.preventDefault();
});
Sign up to request clarification or add additional context in comments.

Comments

1

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');
    });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.