我已经设置了post xmlhttprequest,它工作得很好。但是,我希望将responseText设置为接收数组中的多个变量,以逗号分隔或其他形式。
这就是我目前获取返回的php echo命令的方法。
var return_data = hrequest.responseText;也许是这样的?
var update = new Array();
if(response.indexOf('|$|' != -1)) {
update = response.split('|$|');
alert(update[0]);
document.getElementById("button1").value=update[1];
document.getElementById("button2").value=update[2];
}发布于 2013-01-14 01:25:12
从php以JSON格式发送数据会更容易。
从php发送JSON:
echo json_encode( $array);从responseText解析为数组:
var return_data_array = JSON.parse(hrequest.responseText);https://stackoverflow.com/questions/14306039
复制相似问题