window.History.pushState works only once on server

490 Views Asked by At

I am working on Yii project and following this link to filter results of cListview on a page without reloading it.

http://www.yiiframework.com/forum/index.php/topic/36820-clistview-ajax-filtering-with-history-enable/

I am using the same code as in link i.e

<?php
Yii::app()->clientScript->registerScript('search',
"$('#searchform').change(function(event) {
        SearchFunc();
        return false;
});
jQuery('input').keydown(function (event) {
 if (event.keyCode && event.keyCode == '13') {
    SearchFunc();
    return false;
 } else {
    return true;
 }
});
function SearchFunc()   {
 var data = $('input').serialize();
 var url = document.URL;
 var params = $.param(data);
 url = url.substr(0, url.indexOf('?'));
 window.History.pushState(null, document.title,$.param.querystring(url, data));
}
");
?>

The code is working fine on localhost and replacing old search results with new one on form change, but on live server, it replaces results only once. From second time it only appends new search results on top of old ones.

Please help me solve this.

0

There are 0 best solutions below