I used to be a rookie (though it's still very-_-| | The technology of asynchronous loading and callback function is very yearning, but also has not been used, this time because the page logic is too complex, a bunch of request logic, if still in order to request, the speed of the page ... The leader is scratching his head again.
People are forced out, so to study the next asynchronous and callback, the following is only my own opinion ah, for their own memories, do not like to spray:
The amount ... The amount ... Forget it, typing good trouble, directly on the code bar, it is not to read
Getalarmdata (Prov,function (arralarm) {
Console.log (Arralarm);
});
function Getalarmdata (areaid,callback) {
var arr = [];
$.ajax ({
Type: ' GET ',
URL: ' URL ',
DataType: ' Script ',
Cache:false,
Async:false,
Success:function () {
var n = alarminfo.count;
var arrdata = Alarminfo.data;
for (var i = 0;i<3;i++) {
var style = i==0 && 9 | | I==1 && 7 | | i==2 && 5;
var id = areaid.substr (0,style);
$.each (Arrdata,function (i,v) {
if (V[1].split ('-') [0] = = ID) {
Arr.push (v);
}
})
}
Callback (ARR);
}
})
}