gpt4 book ai didi

javascript - 在这种情况下,如何在 jquery 中传递两个参数?

转载 作者:行者123 更新时间:2023-11-29 21:52:33 25 4
gpt4 key购买 nike

我正在尝试将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com