我有一个表单,在它的操作上我有一个 php 文件,我希望当我单击提交时,它应该首先打开操作 php(意味着在浏览器中查看),然后开始执行其中的代码。
表单标签是这样的
<form action="myScript.php" method="post"></form>
现在发生的事情是,当我单击提交时,它停留在同一页面上并开始执行 php 文件,当它完成时,它会在浏览器中显示脚本文件页面。
You have to execute the PHP in order to generate the page that is shown in the browser as a result of the POST. Even if your PHP is generating the page and then performing a long operation, output buffering and compression will defeat you, so you will need to turn them off. See How to flush output after each `echo` call? for other things you may have to do to get your output to appear immediately.
你可以使用 jquery POST 做任何你想做的事: jQuery.POST
是<input type="submit">
标签内的<form>
标签等。如果不是,那么输入按钮是没有意义的,只是返回 false。您的代码应如下所示:
<form action="myScript.php" method="post">
<input type="submit" />
</form>
这有帮助吗?
凯:-)