ajax传递两个变量的问题

时间:2017-05-12 05:34:45

标签: ajax

我想传递一个ajax两个值。

我有这个

<head>
<script src="scripts/data.js"></script>
</head>
..code..
<form>
<label>Search:</label><input type="text" name=search> 
    <input type=button value="Search" onclick="showData(search.value,type.value)">
    <select >
    <option name=type value=""></option>
    <option value='PRD'>Production</option>
    <option value='TST'>Test</option>
    <option value='UAT'>UAT</option>
    <option value='DEV'>Development</option>
    <option value='DIS'>Disaster</option>
    </select>

data.js是

function showData(str, str1) {
if (str == "") {
    document.getElementById("txtHint").innerHTML = "";
    return;
} else {
    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 (this.readyState == 4 && this.status == 200) {
            document.getElementById("txtHint").innerHTML =    this.responseText;
        }
    };
    xmlhttp.open("GET","getdata.php?q="+str+"&t="+str1);
    xmlhttp.send();
}

}

当我按下按钮时,我得到的第二个变量是未定义的。

我缺少什么?

0 个答案:

没有答案