我有这部法律。
var file = getUrlVars()["file"];
if(file){
document.getElementById( search ).value = file;
}
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
It reads the parameter file from url and then puts the value in the search field. The search field is ajax powered, when a user enters a letter it starts searching and outputs results. The problem is that when the scripts puts the value in the search field nothing happens, how do i make the search to fire up?
这是我的搜索领域。
<input type="text" id="search" class= search_input />
UPDATE: My Ajax search code is this
// Search
$(document).ready(function()
{
$(".search_input").focus();
$(".search_input").keyup(function()
{
var search_input = $(this).val();
var keyword= encodeURIComponent(search_input);
var yt_url= http://domain.com/search.php?q= +keyword;
$.ajax({
type: "GET",
url: yt_url,
success: function(response)
{
$("#result").html( );
if(response.length)
{
$("#result").append(response);
}
else
{
$("#result").html("<div id= no >No results</div>");
}
}
});
});
} );