Home > Web Front-end > JS Tutorial > jquery multi-asynchronous management usage records

jquery multi-asynchronous management usage records

伊谢尔伦
Release: 2016-11-21 13:15:18
Original
1022 people have browsed it

  $.when() passes multiple deferred

var ajaxBatch=[];
//构建deferred数组
...
$.when.apply($,ajaxBatch).done();
Copy after login


  done() The argument structure in the callback is inconsistent

 There will be three situations:

 No parameters

$.when()一个deferred参数: [data, textStatus , jqXHR] #假定 x代表[data,textStatus,jqXHR]结构
$.when()多个deferred参数: [x1,x2,x3]
Copy after login


 Are you drunk? How to handle it uniformly? ?

Currently using the structure to determine the innermost data

.done(function(){
var params=[].slice.call(arguments);
if(typeof params[0][0] !='object'){ //第二种情况返回undefined
params=[];
params[0]=[].slice.call(arguments);
}
//然后遍历结果吧
});
Copy after login



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template