duanniying2342 2013-05-08 20:02
浏览 38

JavaScript搜索脚本无法在Internet Explorer中运行?

I've the following search script but it doesn't seem to be working at all in IE. It always comes back with the "Sorry, we couldn't find anyone using that search criteria..." error.

The code is as follows:

<?

$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>

The HTML form is as expected so I won't include it apart from the last submit button in case that helps:

<div class="profilebutton" onclick="search();">Search</div>
<div class="boxleft" id='searchres_results' style='display:none;'>
</div>
  • 写回答

1条回答 默认 最新

  • dt4320279 2013-05-08 20:12
    关注

    For Sorry, we couldn't find anyone using that search criteria... to be outputted you need to reach that line of code. That means that snresnum == '0' is true.

    This is because you set:

    var snresnum = $("#searchresults_number").html();
    

    And $("#searchresults_number").html() is '0'.

    Be sure the value inside the element with the id="searchresults_number" is generated correctly in ajsearch.php. It is always 0 now.

    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler