Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP、AJAX、MYSQLI和IE9未按预期输出_Php_Jquery_Mysql_Ajax_Mysqli - Fatal编程技术网

PHP、AJAX、MYSQLI和IE9未按预期输出

PHP、AJAX、MYSQLI和IE9未按预期输出,php,jquery,mysql,ajax,mysqli,Php,Jquery,Mysql,Ajax,Mysqli,我使用PHP、AJAX和MYSQLI的组合来加载用户键入内容的建议(每次按键时都会触发加载)。这在chrome、ie10、firefox、safari等浏览器中都能很好地工作。然后我在IE9上试用了它,它只显示了“无建议”(如果没有找到匹配项,我就编码这样做)。我唯一的想法是,这可能是我在谷歌上读到的一个缓存问题,但我尝试了所有的建议。。我到了我开始的地方。。“没有建议”。所以,我被难住了。以下是我的AJAX代码: function activelyLoad(passedInfo, insert

我使用PHP、AJAX和MYSQLI的组合来加载用户键入内容的建议(每次按键时都会触发加载)。这在chrome、ie10、firefox、safari等浏览器中都能很好地工作。然后我在IE9上试用了它,它只显示了“无建议”(如果没有找到匹配项,我就编码这样做)。我唯一的想法是,这可能是我在谷歌上读到的一个缓存问题,但我尝试了所有的建议。。我到了我开始的地方。。“没有建议”。所以,我被难住了。以下是我的AJAX代码:

function activelyLoad(passedInfo, insertInto, urlInLib)
{
    if (passedInfo.length==0)
  { 
  document.getElementById(insertInto).innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(insertInto).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","../lib/"+urlInLib+"?q="+passedInfo,true);
xmlhttp.send();
}
下面是我正在加载的一个PHP文件:

<?php
include('config.inc.php');
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Pragma: no-cache' );
$full = $_GET['q'];
$fullAr = explode(" ", $full);
$count = count($fullAr);
$var = $fullAr[0];
$query = "SELECT * FROM StudentInfo WHERE (StudentFirstName LIKE '%$var%' OR StudentPrefferedName LIKE '%$var%' OR StudentLastName LIKE '%$var%')";
$response = "";
if ($count >= 2) {
    $var2 = $fullAr[1];
    $query = "SELECT * FROM StudentInfo WHERE ((StudentFirstName LIKE '%$var%' OR StudentPrefferedName LIKE '%$var%') AND StudentLastName LIKE '%$var2%') OR ((StudentFirstName LIKE '%$var2%' OR StudentPrefferedName LIKE '%$var2%') AND StudentLastName LIKE '%$var%')";
}
$result = mysqli_query($connection, $query);
$num_results = mysqli_num_rows($result);
if ($num_results > 0) {
while ($row = mysqli_fetch_array($result)) {
    $id = $row['StudentID'];
    $functionList = "\"activelyLoad($id, 'detDiv', 'addtable.php'),showElem('#details')\"";
    $functionList2 = "\"logLoad($id),  showElem('#contactDets')\"";
    if(strcmp($row['StudentPrefferedName'], '') != 0){
    $response .= ("<tr><td>" . $row['StudentFirstName'] . " \"" . $row['StudentPrefferedName'] . "\" " . $row['StudentLastName'] . "</td><td><button type='button' onmousedown=" . $functionList . " onclick=" . $functionList2 . ">Get details</button></td></tr>");
    }
    else{
        $response .= ("<tr><td>" . $row['StudentFirstName'] . " " . $row['StudentLastName'] . "</td><td><button type='button' onmousedown=" . $functionList . " onclick=" . $functionList2 . ">Get details</button></td></tr>");
    }
}
}
else $response = "No suggestions";
echo($response);
mysqli_close($connection);
?>

这是我的问题吗?它怎么会无效?如果此处出现错误,浏览器如何才能访问AJAX加载“无建议”?

在许多其他问题中,您试图将AJAX结果作为
.innerHTML
属性转储到
元素中

Internet Explorer有一个错误,在该错误在IE10中修复之前,您无法通过
.innerHTML
设置
标记的内容

错误报告:


您最好创建一个
,并设置
.innerHTML

代码中可爱的漏洞。。。享受服务器pwn3d.post生成的html。跨浏览器问题总是html问题。
$id
是一个数字吗?IE9可能不喜欢数字ID,因为它们在HTML4中是不允许的。如果您有jQuery(正如您标记的问题一样),那么请使用内置的$.AJAX方法,而不是尝试使用自己的方法。那么,IE9中的浏览器控制台说了什么?它显示了什么错误?谢谢。我继续使用jQueryPost方法,并且能够继续使用我的表设置,这对我来说具有设计优势。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META HTTP-EQUIV=”Pragma” CONTENT=”no-cache”>
<title>XXXXXXX</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="../lib/searchScripts.js"></script>
</head>
<body>
<h1>XXXXXXXX</h1>

<p>Please select one of the following options:</p>
<ul>
<li><a id="searchLink" href="#" onclick="showElem('#search')">Search for a student</a></li>

<div id="search">
<p><b>To find a student, start typing a name in the input field below:</b></p>
<form> 
Student Name: <input type="text" onkeyup="activelyLoad(this.value, 'txtHint', 'gethint.php'), showElem('#suggestions')">
</form>
<div id="suggestions"><h2>Suggestions:</h2> <div id="suggestionsBox"><table id="txtHint"><tr><td>No Suggestions</td></tr></table></div></div>
SCRIPT600: Invalid target element for this operation. for 'document.getElementById(insertInto).innerHTML=xmlhttp.responseText;'