required : jquery.form.js
$(document).ready(function(){
varoptions={
target:'server.php',
beforeSubmit:showRequest,
success:showResponse
//url:url//overrideforform's'action'attribute
//type:type//'get'or'post',overrideforform's'method'attribute
//dataType:null//'xml','script',or'json'(expectedserverresponsetype)
//clearForm:true//clearallformfieldsaftersuccessfulsubmit
//resetForm:true//resettheformaftersuccessfulsubmit
//$.ajaxoptionscanbeusedheretoo,forexample:
//timeout:3000
};
$('#htmlForm').submit(function(){
//insideeventcallbacks'this'istheDOMelementsowefirst
//wrapitinajQueryobjectandtheninvokeajaxSubmit
$(this).ajaxSubmit(options);
//!!!Important!!!
//alwaysreturnfalsetopreventstandardbrowsersubmitandpagenavigation
returnfalse;
});
});//pre-submitcallback
functionshowRequest(formData,jqForm,options){
//formDataisanarray;hereweuse$.paramtoconvertittoastringtodisplayit
//buttheformplugindoesthisforyouautomaticallywhenitsubmitsthedata
varqueryString=$.param(formData);
//jqFormisajQueryobjectencapsulatingtheformelement.Toaccessthe
//DOMelementfortheformdothis:
//varformElement=jqForm[0];
alert('Abouttosubmit:\n\n'+queryString);
//herewecouldreturnfalsetopreventtheformfrombeingsubmitted;
//returninganythingotherthanfalsewillallowtheformsubmittocontinue
returntrue;
}
//post-submitcallback
functionshowResponse(responseText,statusText){
//fornormalhtmlresponses,thefirstargumenttothesuccesscallback
//istheXMLHttpRequestobject'sresponseTextproperty
//iftheajaxSubmitmethodwaspassedanOptionsObjectwiththedataType
//propertysetto'xml'thenthefirstargumenttothesuccesscallback
//istheXMLHttpRequestobject'sresponseXMLproperty
//iftheajaxSubmitmethodwaspassedanOptionsObjectwiththedataType
//propertysetto'json'thenthefirstargumenttothesuccesscallback
//isthejsondataobjectreturnedbytheserver
alert('status:'+statusText+'\n\nresponseText:\n'+responseText+
'\n\nTheoutputdivshouldhavealreadybeenupdatedwiththeresponseText.');
}
</script>
</head>
<body>
<formid="htmlForm"autocomplete="on"method="post"action="r.aspx">
<inputtype="submit"value="submit"/>
</form>
</body>
</html>server
<%
Response.Write("success");
%>