Ajax asynchronous request background data processing

 1 $.ajax({
 2             type: "POST",
 3             url: "./rule/list/device/list",
 4             data: JSON.stringify(obj),
 5             dataType: "json",
 6             headers: {
 7                 'Accept': 'application/json',
 8                 'Content-Type': 'application/json'
 9             },
10             success: function (data) {
11                 for (var i = 0; i < data.length;i++ de-duplicate//12) {
                     
13                     var hasSame = false;
14                     for(var j=0;j < temp.length;j++){
15                         if(temp[j].deviceId == data[i].deviceId){
16                             hasSame = true;
17                             break;
18                         }
19                     }
20                     if(hasSame){
21                         continue;
22                     }
23                     var html = '<tr><td><input type="checkbox" name="checkedId2" value="' + data[i].deviceId + '" onclick="chooseStoreDevice(' + data[i].deviceId + ')" id="d_' + data[i].deviceId + '"></td>' +
24                             '<td>' + data[i].deviceCode + '</td><td>' + data[i].deviceName + '</td><td>' + data[i].storeName + '</td></tr>';
25                     $("#tb3").append(html);
26                     temp.push(data[i]);
27                 }
28 //                    console.log(JSON.stringify(temp));
29             }
30         });
31 
32     }

Note: The headers here are required, otherwise the background cannot accept the request.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324933140&siteId=291194637