简体   繁体   中英

Update div that has a PHP page with form loaded, after submit

I have a problem.

Basically, I have a PHP page loaded in a div in the index page, using the following JQuery script:

 $("#link").click(function () { $("#content").load("page.php"); }); 

The PHP is loaded into the div when I click a link in the index.php, but that PHP page has a form, and when I submit that form (which have action='' empty because I want to handle this form with the same PHP) the index.php is reloaded and the original content of the div restores to the first element that appears there when the page loads.

So I need your help with this issue, I appreciate any help.

Cheers!.

You can detect via PHP that it was submitted, then run the jquery:

if (!empty($_POST))//if GET change to $_GET
{
echo '$("#content").load("page.php");'
}

dont forget to add the script tags to

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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