Ajax asynchronous request Refresh _ajax related

Source: Internet
Author: User

In the Web site Refresh method, Ajax refresh is a good user experience refreshing way, in combination with SSH and other popular framework! The most common! Here is a demo that uses an Ajax refresh 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 = = ' dangerous ') {$ ('. Table-thtr '). After (' <tr class= ' dat ATR Error-tr "> ' + ' <td></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+ ' &L
           T;/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+ ' &L T;/td> ' + ' <td><a href= ' warningaction!waringinfor.action?
        Wid= ' +data[i].wid + ' "> Details </a></td> ' + ' </tr> '); }else{$ ('. Table-thtr '). After (' <tr class= "Datatr" > ' + ' <td></td> ' + ' <td> ' +data[i].pname+ ' </td> ' + ' <td> ' +data[i].uname+ ' &L
         T;/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+ ' &L T;/td> ' + ' <td> ' +data[i].pstate+ ' </td> ' + ' <td><a href= ' WarningAction!waringinfor.action?
        Wid= ' +data[i].wid+ ' > Details </a></td> ' + ' </tr> ');
   }

       }
     }
    });
};
 </script>

And in the background of the warningaction!waringinfor.action transfer two parameters, to achieve the requirements of this method! Returns 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 the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.