The ultimate experience of ajax local and overall refreshing, the ultimate experience of ajax local

Source: Internet
Author: User

The ultimate experience of ajax local and overall refreshing, the ultimate experience of ajax local

This article will introduce how to use jquery's load method to perform partial refresh. The load method is simple, but we need to work harder to integrate it into the public projects of jfinal and bootstrap.

First, let's talk about the solution.

$p.load(url,data,function(response,status,xhr))

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

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

location.href 

Therefore, we also need to provide a parameter.

Therefore, we encapsulate three attributes.

// Locally load String elementId = getPara ("elementId"); String loadPage = getPara ("loadPage"); // the 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"

Note:

. Jfinal encapsulates the callback functions provided by three attributes to the front-end.

. Jsp will pass the corresponding parameters to jfinal

Then, let's 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 this parameter is specified, you can call $ ("#" + json. elementId ). load (common. loadPath + json. loadPage + common. viewType );}}}

I provide a similar method, mainly based on the solution given in the title.

Notes

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

<! DOCTYPE html PUBLIC "-// WC // dtd html. transitional // "" http://www.w.org/TR/html/loose.dtd "> 

Conclusion: All the content in this article is over. I think you have also had the ultimate experience. More content will be updated on this site later. Please stay tuned.

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.