Elumalai Kaliyaperumal
Elumalai Kaliyaperumal

Reputation: 1520

Server side code to reload page through jQuery ajax call in PHP

Automatically reload page through ajax call in PHP. Code should be done at server side not in JS. Is it possible in PHP through ajax call?

Upvotes: 1

Views: 433

Answers (1)

Mohammed Ahmed
Mohammed Ahmed

Reputation: 455

use this ajax request in javascript

 var xhttp = new XMLHttpRequest();
  xhttp.open("GET", "http://yoursite.com/somefile.php?action=reload", true);
    xhttp.send();

and this in php

if ( isset($_GET["action"]) && $_GET["action"] == "reload" ) {
    header("Refresh:0");
 }

Upvotes: 1

Related Questions