Home > Article > Web Front-end > Using ajax to implement asynchronous refresh requests
ajax refresh is a refreshing method with good user experience. This article mainly introduces ajax asynchronous request refresh. Interested friends can refer to
Among the methods of website refresh, ajax refresh It is a refreshing method with good user experience, combined with popular frameworks such as ssh! The most commonly used! The following is a demo that commonly uses an ajax to refresh the form.
$(document).ready(function () { testchaxun(); setInterval("testchaxun()",5000); }); function testchaxun(){ /* var selectId = $('#proviace').val(); */ $.ajax({ type : "POST", /* cache: false, */ url : "WarningAction!warningdefQuery1.action", dataType : "json", success : function(data) { $('tr').remove('.datatr'); for(var i=0;i<data.length;i++){ if(data[i].pState == '危险'){ $('.table-thtr').after('<tr class="datatr error-tr">'+ '<td><img class="picture" src="'+data[i].pPic+'"/></td>'+ '<td>'+data[i].pName+'</td>'+ '<td>'+data[i].uName+'</td>'+ '<td>'+data[i].bHomenum+'</td>'+ '<td>'+data[i].bNumber+'</td>'+ '<td>'+data[i].eStart+'</td>'+ '<td>'+data[i].wType+'</td>'+ '<td>'+data[i].wTime+'</td>'+ '<td>'+data[i].pAddress+'</td>'+ '<td>'+data[i].uName+'</td>'+ '<td>'+data[i].pState+'</td>'+ '<td><a href="WarningAction!waringInfor.action?WId='+data[i].wId +'">详情</a></td>'+ '</tr>'); }else{ $('.table-thtr').after('<tr class="datatr">'+ '<td><img class="picture" src="'+data[i].pPic+'"/></td>'+ '<td>'+data[i].pName+'</td>'+ '<td>'+data[i].uName+'</td>'+ '<td>'+data[i].bHomenum+'</td>'+ '<td>'+data[i].bNumber+'</td>'+ '<td>'+data[i].eStart+'</td>'+ '<td>'+data[i].wType+'</td>'+ '<td>'+data[i].wTime+'</td>'+ '<td>'+data[i].pAddress+'</td>'+ '<td>'+data[i].uName+'</td>'+ '<td>'+data[i].pState+'</td>'+ '<td><a href="WarningAction!waringInfor.action?WId='+data[i].wId+'">详情</a></td>'+ '</tr>'); } } } }); }; </script>
The WarningAction!waringInfor.action in the background receives and sends two parameters to realize the necessary conditions for requesting this method! Return a json
public String waringInfor(){ w= warningService.getWarningByWid(WId); if (w!=null) { if (w.getPId()!=null) { p =patientService.getPatientByPId(w.getPId()); } } if (p!=null) { if (p.getPId()!=null) { s= sickroomService.getSickroomByPid(p.getPId()); } if (p.getPEquipmentid()!=null) { e= equipmentService.getEquipmentByEId(p.getPEquipmentid()); } } return "waringInfor"; };
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Ajax php realizes three-level linkage of product classification
About the output stream at the end of the servlet in Ajax technology
Ajax technology composition and core principle analysis
The above is the detailed content of Using ajax to implement asynchronous refresh requests. For more information, please follow other related articles on the PHP Chinese website!