简体   繁体   中英

Refresh a PHP include using jQuery

I have a PHP include file which contains a lot of user actions ie login, logout, toolbars, buttons etc. This file is the same across the entire site hence the include. Inside the include I have jQuery scripts which call other files to validate a user login, log them out, user menus etc. This include is the entire header of the site.

Now I want to reload this include after say a user logs into the site but I do not want to reload the entire page and they could be performing action which I dont want them to lose or I dont want them to be stored as cookies/sessions.

There is a container div (#dynamicHeader for for example) which holds the include.

I have tried the .load() from within the include but that does nothing. I know the content is being replaced correctly as I have tried .html("logged in") and the container div displays this. Does anyone know a way to reload the include from within the include?

Many thanks

You could use $.get() Documentation Here . You would call the page to be included here and set the html of #dynamicHeader to the returned html in the callback.

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