mardi 24 février 2015

jquery Page refresh not updating query string value

I am using following java script code to refresh the same page with the value in the text box as a query string parameter, page is refreshed but value in query string is not getting updated.



$(document).ready(function(){
$("#Custom_csr_sbox").val(getParameterByName('k'));
$("#Custom_csr_SearchLink").click(doSearch);
$("#Custom_csr_sbox").keypress(function(e) {
if(e.which == 13) {
doSearch();
}
});
});
function doSearch()
{
debugger;
var queryText = $("#Custom_csr_sbox").val();
var query = "https://teams/projects/search/results.aspx";
var contextSite = getParameterByName('u');
if(contextSite=="")
{
query+= "?k=" + queryText;
}
else
{
query+= "?u=" + contextSite + "&k=" + queryText;

}
document.location.href=query;
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

Aucun commentaire:

Enregistrer un commentaire