-3

我有这个使用 ajax 的 php

cotizaciones.php

        <script>
        function showUser(str)
        {
            if (str == "")
            {
                document.getElementById("txtHint").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("txtHint").innerHTML = xmlhttp.responseText;
                }
            }
            xmlhttp.open("GET", "getuser.php?q=" + str, true);
            xmlhttp.send();
        }
    </script>

我有另一个如上所述的脚本,除了它被称为 calcularCuotas(cuotas) 并且最后几行是:

xmlhttp.open("GET", "getuser.php?c=" + str, true);
                xmlhttp.send();

身体标签包含:

<select name="users" onchange="showUser(this.value)">
<select name="cuotas" onchange="calcularCuota(this.value)">

文件getuser.php

    <?php 
$q = $_GET["q"]; 
$c = $_GET["c"]; 
?>

当我尝试使用它时,php 会抛出这个错误:

注意:未定义的索引:第 3 行 C:\wamp\www\Cotizacion\getuser.php 中的 c

感谢帮助 :)

4

2 回答 2

0

使用 Jquery 的 Ajax 库,这只是一个建议。

jQuery:阿贾克斯

于 2013-04-10T16:07:28.500 回答
0

在您的第一个代码块中,即 cotizaciones.php

xmlhttp.open("GET", "getuser.php?q=" + str, true);

它不包含 c 作为查询字符串,因此您会收到错误 undefined index c

于 2013-04-10T16:02:21.547 回答