我使用此代码发送整数的一维数组,但如何使其发送和接收由整数和字符串组合形成的二维数组,例如 [此处的数字] [“此处的文本”] 但 url 有一个限制,因此我可以不要做一个大数组
//Send data to php
var queryString ="?";
for(var t=0;t<alldays.length;t++)
{
if(t==alldays.length-1)
queryString+="arr[]="+alldays[t];
else
queryString+="arr[]="+alldays[t]+"&";
}
ajaxRequest.open("POST", "forbidden.php" + queryString, true);
ajaxRequest.send(null);
}
// Create a function that will receive data sent from the server(sended as echo json_encode($array))
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var myArray = ajaxRequest.responseText.replace("[","").replace("]","").replace(/"/g,"").split(",");
for(var i=0; i<myArray.length; i++) { alldays[i] = parseInt(myArray[i]); }
}}