简体   繁体   English

执行PHP脚本而无需重新加载页面

[英]performing php script without reloading the page

<form action ="send.php" name ="userdetails" onsubmit="display(); return false;">

although this does perform the send.php script, it loads the send.php page and the content of the current page is lost. 尽管此操作确实执行send.php脚本,但它会加载send.php页面,并且当前页面的内容会丢失。

I need to perform the following, once the form is submitted - an email should be sent. 提交表单后,我需要执行以下操作-应该发送电子邮件。 However the current page is not to be changed. 但是,当前页面不会更改。 What is the best way to accomplish this? 做到这一点的最佳方法是什么? Thank you 谢谢

Setting a value for action="..." will always redirect you to a new page. action="..."设置值将始终将您重定向到新页面。

For what you want to do, AJAX is perfect. 对于您想做的事情,AJAX是完美的。 It allows you to run a PHP script without leaving the page you are on. 它允许您运行PHP脚本而无需离开页面。 I would check out jQuery's AJAX capabilities . 我会检查一下jQuery的AJAX功能

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

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