prifs prifs - 1 year ago 52
PHP Question

PHP - How do facebook change the facebook/message/username to facebook/message/username2 on the same page?

I'm trying to create a real-time chat on my website. One of the functions I want to imitate is how changes not only content of the webpage but also the url without refreshing. I think this is a lot cleaner more efficient.

My current process is just a

with a
var id = $(this).attr("id")
running with an Ajax.

Answer Source

To add and modify history, use history.pushState() and history.replaceState() methods, respectively.

window.history.pushState('username2', 'Title', '/username2.php');

To know more visit: History API

The only way to create single page apps is to use Angular JS. To know more visit: Angular JS

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download