Submit without refresh in php

前端 未结 4 1163
星月不相逢
星月不相逢 2021-01-21 15:02

I\'ve read a lot of post regarding the topic. I\'ve seen lots of answers and pointing to use ajax. Is there any other way to not refresh the page on form submit?

E.g Sam

相关标签:
4条回答
  • 2021-01-21 15:14
    <form method="post" onSubmit="event.preventDefault()">
    <input type="radio" name="test" value="Start">Start<br />
    <input type="radio" name="test" value="Stop">Stop<br />
    <input type="submit" value="GO">
    </form>
    

    You don't need to use any iframe for this short purpose... as you looking for a javascript methods, I will recommend you to use event.preventDefault() inside the form tag in html... it will not let the form submitted and refresh the page...

    0 讨论(0)
  • 2021-01-21 15:18

    I think you may use AJAX For that it's better ways to submit form without page refresh

    0 讨论(0)
  • 2021-01-21 15:24

    Yes, you can use a form embedded in an iframe.

    0 讨论(0)
  • 2021-01-21 15:25

    Yes, you can use iframes:

    <iframe id="myIframe" name="myIframe" width="0" height="0" frameborder="0"></iframe>
    <form method="post" target="myIframe" action="script.php">
        <input type="radio" name="test" value="Start">Start<br />
        <input type="radio" name="test" value="Stop">Stop<br />
        <input type="submit" value="GO">
    </form>
    
    0 讨论(0)
提交回复
热议问题