从JavaScript表单提交运行PHP

时间:2022-11-24 20:11:36

Can anyone explain how to run PHP code from within javaScript for submit?

任何人都可以解释如何从javaScript中运行PHP代码提交?

Currently I submit the form to a page.php, connect to MySQL, run some queries then build up the HTML and echo it out.

目前我将表单提交到page.php,连接到MySQL,运行一些查询然后构建HTML并将其回显。

However, I want to do this without going to the page.php as I am trying to show the results in an ajax dialog using JQuery-UI. It works, just I have to submit to page.php to make it happen.

但是,我想这样做而不去page.php,因为我试图在使用JQuery-UI的ajax对话框中显示结果。它工作正常,我必须提交到page.php来实现它。

Would I do something like build up the code in Javascript writelin statements and dynamically load a div or something?

我会做一些事情,比如在Javascript writelin语句中构建代码并动态加载div或其他东西吗?

1 个解决方案

#1


1  

Use jQuery's post() method to send the request to page.php from JavaScript asynchronously. You can use the success option to show the dialog http://api.jquery.com/jQuery.post/

使用jQuery的post()方法异步地从JavaScript发送请求到page.php。您可以使用success选项显示对话框http://api.jquery.com/jQuery.post/

#1


1  

Use jQuery's post() method to send the request to page.php from JavaScript asynchronously. You can use the success option to show the dialog http://api.jquery.com/jQuery.post/

使用jQuery的post()方法异步地从JavaScript发送请求到page.php。您可以使用success选项显示对话框http://api.jquery.com/jQuery.post/