MooTools Asynchronous Commit

Source: Internet
Author: User

<script type= "Text/javascript" >
function Ajax () {
Ajaxsubmit (' detailform ', ' detail ', ' submit ', ' detailform ');
Ajaxsubmit (' Catalogid ', ' Search ', ' change ', ' articleform ');

function Setflag (flag) {
document.getElementById ("Articleparambean.flag"). Value=flag;
}
}
</script>

<body onload= "Ajax ()" >

<s:form action= "articlesearch.do" method= "post" id= "Articleform" >
<div id= "Search" >
<%@ include file= "articlesearch.jsp"%>
</div>
<s:hidden name= "Articleparambean.flag" ></s:hidden>
</s:form>

<s:form action= "articledetailsearch.do" method= "post" id= "Detailform" >
<div style= "width:99%" id= "Detail" >
<%@ include file= "articlelist.jsp"%>
</div>
</s:form>

<script type= "Text/javascript" >
$ (' Articleform '). Set (' send ', {
Onsuccess:function (response) {
if (document.getElementById ("Articleparambean.flag"). value== ' Search ') {
$ (' detail '). InnerHTML = response; Page Write back
}else{
$ (' search '). InnerHTML = response;
}},
Onfailure:function () {$ (' search '). Set (' Text ', ' the request failed. ');}
}
). Addevent (' Submit ', function (event)
{Event.preventdefault ();
This.send ();
}
);
</script>

</body>

The principle of MooTools asynchronous submission:

Divide the page into sections, submit them in different form, and write different areas of the page according to the submitted form.

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.