user3555483
user3555483

Reputation: 190

Ajax response in browser history

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
}

Upvotes: 0

Views: 794

Answers (1)

Jarod Denison
Jarod Denison

Reputation: 21

Make sure that you're setting headers properly.

Header('Content-Type: application/json');
Header("Cache-Control: no-store");

Upvotes: 1

Related Questions