这适用于Chrome和IE,但不适用于Firefox,我无法弄清楚原因。在此先感谢,这让我花了很长时间才弄明白。
这是我的代码:
<script type="text/javascript">
$(document).ready(function() { //SEARCH FORM
$('#wrapper').delegate('#device_search','keyup', function(e) {
var searchquery = $('#device_search').val();
localStorage.setItem("searchquery", searchquery);
if (searchquery) {
$(".server_list_div").hide();
$(".search_results_div").show();
var options = {
target: '',
dataType: 'html',
beforeSubmit: showRequest_searchform,
success: showResponse_searchform
};
$("#search_form").ajaxSubmit(options);
function showRequest_searchform(formData, jqForm, options){
return true;
}
function showResponse_searchform(responseText, statusText, xhr, $form){
$(".search_results_div").html(responseText);
}
return false;
} else {
$(".scroll_div").show();
$(".scroll_div_results").hide();
}
});
});
</script>
这是我得到的错误:
答案 0 :(得分:1)
答案 1 :(得分:0)
尝试将您的功能移出if
声明:
$(document).ready(function() {
function showRequest_searchform(formData, jqForm, options){
return true;
}
function showResponse_searchform(responseText, statusText, xhr, $form){
$(".search_results_div").html(responseText);
}
return false;
//SEARCH FORM
$('#wrapper').delegate('#device_search','keyup', function(e) {
var searchquery = $('#device_search').val();
localStorage.setItem("searchquery", searchquery);
if (searchquery) {
$(".server_list_div").hide();
$(".search_results_div").show();
var options = {
target: '',
dataType: 'html',
beforeSubmit: showRequest_searchform,
success: showResponse_searchform
};
$("#search_form").ajaxSubmit(options);
} else {
$(".scroll_div").show();
$(".scroll_div_results").hide();
}
});
});