Submit form with Spry.DataUtils.ServerAction
Here is a quick and dirty example of using the Spry.DataUtils.ServerAction in the Adobe Spry 1.6.1 Framework. (Form post back without page refresh). Hopefully Adobe will get off there ass and continue work on this framework as it has great potential. And I really like using it.
Surprisingly there is very little in the documentation about this wonderful function, only after digging through the framework did I discover this great little feature. and it has come in very handy in many previous projects. for more info on this function feel free to dig thought the SpryDatUtils.js file found in the framework.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <% Option Explicit Dim FormAction : FormAction = Request.ServerVariables("URL") If Request.ServerVariables("REQUEST_METHOD") = "POST" And Request.Form("Password") > "" Then 'Here is where you would write your logic for processing the form values posted 'You could easily put this code in a seprate file/directory. that is just for 'processing script posts from your ajax forms. Response.Write("You posted the form, notice the page did'nt change?") Response.End End If %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Submit Form With Spry.DataUtils.ServerAction</title> <script language="JavaScript" type="text/JavaScript"> <!-- function beforeOnSubmit(form){ //var theForm = document.getElementById(form); alert(form); //var ret = false; //Spry.Widget.Form.validate(form); Spry.DataUtils.ServerAction('Login','SupportResponse','SubmitError',true,'',''); //} //return ret; } function SupportResponse(req){ alert("SUCCESS: " + req.xhRequest.responseText); //var response = req.xhRequest.responseText; } function SubmitError(req){ alert("ERROR: The server did not respond, Please resubmit your request."); } //--> </script> <script src="SpryDataUtils.js" type="text/javascript"></script> </head> <body> <form action="<%= FormAction %>" method="POST" name="Login" id="Login" onSubmit="beforeOnSubmit(this.name); return false;"> <input type="text" name="Password"><input type="submit" name="Submit Form" id="Submit Form" value="Login"> </form> </body> </html> |
You can find out more about the spry framework @ http://labs.adobe.com/technologies/spry/home.html
Adobe Spry Documentation: http://labs.adobe.com/technologies/spry/docs.html
Adobe Spry Download: http://www.macromedia.com/go/labs_spry_download