Ajax form submission

Source: Internet
Author: User

Ajax form submission
Ajax form submission serialize ()

Front-end code:

<Script src = "js/jquery-1.11.2.js"> </script> 
<Script type = "text/javascript"> $ (function () {$ ('# userName, # password, # mobile '). on ('keyup', function (e) {// give # userName, # password, # mobile binds a keyup event to three elements, if (e. keyCode = 13) {// if the user presses the Enter key (the keyCode of the Return key is 13), the user clicks it. loginBtn submit button. Trigger the submit event $ ('. loginBtn '). trigger ('click') ;}}); var data =$ ("# myForm "). serialize (); $ (". loginBtn "). on ("click", function () {var data = $ ("# myForm "). serialize (); $. ajax ({url: "ajaxFormHandler. ashx ", data: data, success: function (data) {alert (data) ;}})}); </script>

Background code (common application processing program) ajaxFormHandler. ashx

 

Using System; using System. Collections. Generic; using System. Linq; using System. Web; namespace JqueryUI {////// AjaxFormHandler summary ///Public class ajaxFormHandler: IHttpHandler {public void ProcessRequest (HttpContext context) {context. response. contentType = "text/plain"; var userName = context. request ["userName"]; // receives the value var mySelect = context. request ["mySelect"]; var pas = context. request ["password"]; var mobile = context. request ["mobile"]; // context. response. write ("Hello World");} public bool IsReusable {get {return false ;}}}}



 

Zookeeper

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.