Home >Backend Development >PHP Tutorial >ajax asynchronous request refresh method
ajax refresh is a refreshing method with good user experience. This article mainly introduces ajax asynchronous request refresh. Interested friends can refer to it. I hope it can help everyone.
Among the methods of website refresh, ajax refresh is a refresh 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"; };
Related recommendations:
javascript - ajax refresh problem
php +ajax creates a non-refresh message board, phpajax refreshes the message board_PHP tutorial
php+ajax implements non-refresh paging, phpajax refreshes the paging
The above is the detailed content of ajax asynchronous request refresh method. For more information, please follow other related articles on the PHP Chinese website!