Extreme experience Ajax local and global refresh _ajax related

Source: Internet
Author: User

This article will show you how to use the jquery load method for local refresh, the load method itself is very simple, but want to integrate into the jfinal and bootstrap public projects, we need to work harder.

First, I'll start with the plan.

$p. Load (url,data,function (RESPONSE,STATUS,XHR))

Then we need to provide at least two parameter URLs and jquery objects for the callback function of the AJAX request.

In addition, we may also have the possibility of an address bar overload.

 
 

So, we also need to provide a parameter.

So, we encapsulate three attributes

Locally loaded
    String ElementID = Getpara ("ElementID");
    String loadpage = Getpara ("LoadPage");
    Address bar Jump Path
    String locationurl = Getpara ("Locationurl");
    SetAttr ("ElementID", ElementID);
    SetAttr ("LoadPage", loadpage);
    SetAttr ("Locationurl", Locationurl);
<a href= "${ctx}/mem/logout?elementid=log_tip&loadpage=header_login_tip"
<form class= "Pop_login_" Form "
  action=" ${ctx}/mem/login?callbacktype=closecurrent&elementid=log_tip&loadpage=header_login_ Tip

Attention:

. The Jfinal end encapsulates three properties provided to the front end of the callback function.

. The corresponding parameters are passed to jfinal in the JSP

And then we're going to use

function Dialogajaxdone (JSON) {
  yunm.ajaxdone (JSON);
  if (json[yunm.keys.statuscode] = = YUNM.statusCode.ok | | json[yunm.keys.statuscode] = = YUNM.statusCode.info) {
    if (" Closecurrent "= = Json.callbacktype) {
      close_pop ();
    }
    if (json.locationurl) {
      location.href = Json.locationurl;
    } else {
      //If a rear page is specified, turn
      $ ("#" + Json.elementid). Load (Common.loadpath + json.loadpage + common.viewtype);}}

I offer a similar approach, mainly according to the program given in the title.

Pay attention.

To use the jquery load method, you must add all references to the corresponding page.

 <! DOCTYPE HTML PUBLIC "-//wc//dtd HTML. transitional//en "" Http://www.w.org/TR/html/loose.dtd "> 
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.