我正在尝试将parameter1和parameter2传递到我的update.inc.php中,如何将它们组合在一起以及xmlsend()两者。我只能通过一个!
function insert(){
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status ==200){
document.getElementById('message').innerHTML = xmlhttp.responseText;
}
}
parameter1='bio='+document.getElementById('bio').value;
parameter2='good='+document.getElementById('good').value;
xmlhttp.open('POST','/condition_form/update.inc.php',true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send(parameter1);
}//insert()
最佳答案
send()方法可以接受参数字符串,因此您可以使用 &
连接 2 个参数,例如
xmlhttp.send(parameter1 + '&' + parameter2);
关于javascript - 在这种情况下如何在 jquery 中传递两个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28314514/