0

I am working on localhost/mysite/users. On this page there is user listing and the records are coming from ajax request.

I am facing a strange issue, whenever I press back button and then forward button; on page localhost/mysite/users only the ajax listing is shown, all the page design and other elements are deleted.

Can you please let me know the reason and suggest some solution?

$(document).ready(function() {
        // on page load get listing from this page
        sendReq('localhost/mysite/users');

});

On users page:

if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
    // get users
} else {
    // page rendered
}
user3555483
  • 190
  • 2
  • 11

1 Answers1

1

Make sure that you're setting headers properly.

Header('Content-Type: application/json');
Header("Cache-Control: no-store");
Jarod Denison
  • 21
  • 1
  • 1
  • I found that FF 44 handles the back button without getting tripped up by the AJAX response, but Chrome 51 doesn't. It might be a Chrome specific problem? See also http://stackoverflow.com/questions/9956255/chrome-displays-ajax-response-when-pressing-back-button – sameers Aug 08 '16 at 20:43