1

requests.push($.post('/validate', postData));在一个.each()循环中将 AJAX 请求存储在一个数组中以进行进一步处理。

当我转储这些对象时,Chrome 网络检查器会显示:

Object {readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}

依此类推,对于数组的每个对象。在这些对象中,我想获取responseText(AJAX 查询返回的数据)。我不知道该怎么做。

request.responseText似乎不起作用。

4

2 回答 2

1

您正在记录 ajax 请求,而不是 ajax 响应。

您需要一个成功方法,它允许您获取从服务器返回的响应。

直接来自文档

$.post( "ajax/test.html", function( data ) {
  $( ".result" ).html( data );
});
于 2013-10-17T11:08:11.127 回答
0

试试看,

$.post('/validate', postData,function(data){
    requests.push(data); // push response in array here
});
于 2013-10-17T11:08:07.263 回答