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

标签 javascript jquery parameters

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

相关文章:

javascript - 插件/预设文件不允许导出对象,只能导出函数。删除并保留 babel 安装?使用 webpack 选择?

ruby - 为什么没有正确读取参数?

ruby-on-rails - rails,如何在函数中传递 self

javascript - For 循环不使用 JavaScript 函数的参数

javascript - 导航栏下拉菜单(折叠)在 Bootstrap 5 中不起作用

javascript - 填写文本时按钮移动得很奇怪

javascript - iFrame 的固定宽度为 300px,没有任何样式定义 300px

javascript - 使用 .next() 找到一个 div 并使用 .append() 追加回第一个?

jquery - 如何正确使用延时功能

javascript - 如何设置 Parsley.js 全局配置