Using ajax to implement asynchronous refresh requests

亚连
Release: 2018-05-23 15:35:12
Original
1573 people have browsed it

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[i].pName+''+ ''+data[i].uName+''+ ''+data[i].bHomenum+''+ ''+data[i].bNumber+''+ ''+data[i].eStart+''+ ''+data[i].wType+''+ ''+data[i].wTime+''+ ''+data[i].pAddress+''+ ''+data[i].uName+''+ ''+data[i].pState+''+ '详情'+ ''); }else{ $('.table-thtr').after(''+ ''+ ''+data[i].pName+''+ ''+data[i].uName+''+ ''+data[i].bHomenum+''+ ''+data[i].bNumber+''+ ''+data[i].eStart+''+ ''+data[i].wType+''+ ''+data[i].wTime+''+ ''+data[i].pAddress+''+ ''+data[i].uName+''+ ''+data[i].pState+''+ '详情'+ ''); } } } }); }; 
Copy after login

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"; };
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!