简体   繁体   中英

Refresh part of page with PHP/AJAX

Yes, I know that you can refresh the page every number of seconds with AJAX but I want to be able to do this with PHP. Basically running a PHP script where I can say a command which then triggers AJAX to refresh the page.

I could not find this anywhere, no guide or post on here. Please lead me into the right direction. Thank you.

I am not asking you to write code, I am asking for you to tell me a method to do this.

You can't reload page that sending AJAX request.

If you sending request by JavaScript you can reload page only by JavaScript.

If you send Location header from PHP you get redirect for your XmlHttpRequest object. So use JavaScript for this.

For example you can do AJAX request to your server and write something like this in callback:

function(response) {
    var el = document.getElementById('el');
    el.innerHTML = response;
}

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-2025 STACKOOM.COM