Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript submit form value and refresh page

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #185233
    hanan
    Participant

    Hi
    New to this forum.
    I have the following situation:
    I have a form (inside a larger page) that passes a value through ajax to a php file that uses this value in session.
    I use ajax because I don’t want to page to change. I would like the java-script to refresh the page after it sends the data to to the sessions.php.

    the following code requires me to click twice on the submit button (once to send the value and second to refresh)

    the form:
    <form action=”” method=”post” id=”send_id”>
    <input type=”text” id=”state” name=”state” />
    <input type=”hidden” id=”abbrev” name=”id_num” />
    <input type=”hidden” id=”state_id” name=”state_id” /> <br>
    <input type=”submit” name=”submitBtn”value=”עבור לכרטיסיית מועמד/ת” class=”small button” />
    </form>

    the js
    <script language=”javascript” type=”text/javascript”>
    $(function() {
    $(‘#send_id’).on(‘submit’, function(e) {
    var data = $(“#send_id :input”).serialize();
    $.ajax({
    type: “POST”,
    url: “sessions.php”,
    data: data,
    });
    });
    });

    </script>

    Thanks in advance

    #185239
    hanan
    Participant

    Hi all,
    It’s solved.
    Thanks anyway.
    Hanan

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.