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.