gpt4 book ai didi

javascript - Ajax 提交多值

转载 作者:行者123 更新时间:2023-11-30 13:15:11 25 4
gpt4 key购买 nike

为什么我的 ajax 函数没有使用 get 方法提交两个值

<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction( ){
var ajaxRequest; // The variable that makes Ajax possible!

try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.getElementById("emailconfirm").innerHTML= ajaxRequest.responseText;
}
}

ajaxRequest.open("GET", "Atest.php?<?php echo $PDFPassingArray ?>?Email="+ document.getElementById("email").value, true);
ajaxRequest.send(null);
}

我希望函数提交数组 $pdfpassingArray,它是一个 html_build_query 和表单中的电子邮件元素 ID。目前我只能查看 $pdfPassingarray 值,但不能查看电子邮件值。所以我的问题是,我这部分做对了吗

ajaxRequest.open("GET", "Atest.php?<?php echo $PDFPassingArray ?>?Email="+ document.getElementById("email").value, true);

我的表格

       <form name='myForm'>

<input name="email" id="email"type="text" />
<input name="button" onclick="ajaxFunction()" type="button" />
</form>

最佳答案

您的 URL 字符串中有两个 ?

它的格式应该是 url.php?a=1&b=2

关于javascript - Ajax 提交多值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12270413/

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