使用azax &获取数据;php

Fetching data using azax & php

本文关键字:数据 php 获取 amp azax 使用      更新时间:2023-09-26

当我从组合框中选择一个名称时,与所选名称相关的数据应该使用ajax从mysql表中显示。但这是不可能的。

<html>
<head>
<script>
function showUser (str)
{
    if(str=="")
    {
        document.getElementById("txtHint").innerHTML=="";
        return;
    }
    if(window.XMLHttpRequest)
    {
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmltttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET","getuser.php?q="+str,true);
    xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="""showUser(thiis.value)">
<option value="">Select a person</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<br>
<div id="txtHint">Person List is Here</div>
</body>
</html>

显示一个通知

这是因为您没有读取CSV文件,您显示的数据的字节模式表明包含BIFF数据....的OLE包装器ie。它可能是一个真正的Excel .xls文件。尝试在MS Excel中打开文件(必要时将其重命名为.xls)或Gnumeric或Open/Libre Office Calc中打开。

要在PHP中处理文件,您需要一个能够读取Excel xls文件的PHP库:除了PHPExcel,您还可以在这里找到其他库的列表。