Why browser's address bar is unchanged when using AJAX?

Zdhqasqzzeuyp

New Member
I am using AJAX/JSON combination in Zend Framework. Whenever I click any link in my application, AJAX request is called and content is loaded successfully in DIVs But the address bar is unchanged. How to change address bar according to current active action. Here is My Working Code:
When I use \[code\]http://practice.dev/\[/code\] my index.phtml file is loaded.\[code\]<a href='http://practice.dev/index/one' class='ajax'>One</a><a href='http://practice.dev/index/two' class='ajax'>Two</a><div id="content">content comes here</div>\[/code\]one.phtml:\[code\]$jsonArray = array( 'content' => 'One' );echo Zend_Json::encode( $jsonArray );\[/code\]two.phtml:\[code\]$jsonArray = array( 'content' => 'Two' );echo Zend_Json::encode( $jsonArray );\[/code\]JS Code\[code\]jQuery(document).ready(function(){ jQuery('.ajax').click(function(event) { event.preventDefault(); jQuery.getJSON(this.href, function(snippets) { for(var id in snippets) { jQuery('#' + id).html(snippets[id]); } }); });});\[/code\]When I click link one then string 'One' is loaded in content DIV but address bar is still \[code\]http://practice.dev/\[/code\]. It should be \[code\]http://practice.dev/index/one\[/code\]When I click link two then string 'Two' is loaded in content DIV but address bar is still \[code\]http://practice.dev/\[/code\]. It should be \[code\]http://practice.dev/index/two\[/code\]How is it possible ?Thanks
 
Back
Top