[英]JavaScript search script not working in Internet Explorer?
我有以下搜索腳本,但它似乎在IE中根本不起作用。 它總是返回“對不起,我們找不到使用該搜索條件的任何人...”錯誤。
代碼如下:
<?
$getmystatus = mysql_query("SELECT status FROM members WHERE ID = '$session_memberid'");
while($getmys = mysql_fetch_array($getmystatus))
{
$mystatus = $getmys['status'];
}
?>
<script language=javascript>
function search() {
var snum = 0;
var name = $("#search_name").val();
var city = $("#search_city").val();
var country = $("#search_country").val();
var jobtitle = $("#search_jobtitle").val();
var company = $("#search_company").val();
var minage = $("#search_minage").val();
var maxage = $("#search_maxage").val();
var industry = $("#search_industry").val();
var male = $('#search_male').is(':checked');
var female = $('#search_female').is(':checked');
var token = $("#mtoken").val();
if(!city) { city = ''; } else {}
if(!country) { country = ''; } else {}
if(!jobtitle) { jobtitle = ''; } else {}
if(!company) { company = ''; } else {}
if(!minage) { minage = '0'; } else {}
if(!maxage) { maxage = '0'; } else {}
if(!industry) { industry = ''; } else {}
if ( name != '' ) { snum = snum+1; }
if ( city != '' ) { snum = snum+1; }
if ( country != '' ) { snum = snum+1; }
if ( jobtitle != '' ) { snum = snum+1; }
if ( company != '' ) { snum = snum+1; }
if ( minage != '0' ) { snum = snum+1; }
if ( maxage != '0' ) { snum = snum+1; }
if ( industry != '' ) { snum = snum+1; }
if ( male == true ) { snum = snum+1; }
if ( female == true ) { snum = snum+1; }
if ( snum < 1 ) {
$('#sverif').html('<font color=red>Select al least 1 type</font>');
} else {
$('#searchres_nresults').hide().html("<table border='0'><tr><td><img width=60 src='/images/loading.gif'></td><td>Searching ..</td></tr></table> ").fadeIn();
$('#sverif').html('');
var dataString = "token="+token+"&name="+name+"&city="+city+"&country="+country+"&jobtitle="+jobtitle+"&company="+company+"&minage="+minage+"&maxage="+maxage+"&industry="+industry+"&male="+male+"&female="+female;
$.ajax({
type: "POST",
url: "ajax/ajsearch.php",
async: true,
data: dataString,
success: function(data) {
$("#searchres_results").html(data);
$("#searchres_results").css("display","block");
var snresnum = $("#searchresults_number").html();
if ( snresnum == '0' ) {
$("#searchres_nresults").delay(3000).html("<div class=t23>Sorry, we couldn't find anyone using that search criteria...</div>");
} else {
$("#searchres_nresults").delay(3000).html("<div class=t23>Great news, we've found "+snresnum+" people...</div>");
}
}
});
}
</script>
HTML表單符合預期,因此我將在最后一個“提交”按鈕之外添加該表單,以幫助您:
<div class="profilebutton" onclick="search();">Search</div>
<div class="boxleft" id='searchres_results' style='display:none;'>
</div>
對於Sorry, we couldn't find anyone using that search criteria...
要輸出該信息,您需要到達該行代碼。 這意味着snresnum == '0'
為true
。
這是因為您設置了:
var snresnum = $("#searchresults_number").html();
並且$("#searchresults_number").html()
為'0'
。
確保在ajsearch.php
正確生成了id="searchresults_number"
元素內部的值。 現在總是0
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.