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++) { 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 }
注意:这里headers必须要的,不然后台接受不到请求。