The backend accepts the instance code for passing ajax values, and the backend ajax transmits instances.

Source: Internet
Author: User

The backend accepts the instance code for passing ajax values, and the backend ajax transmits instances.

The backend instance code that accepts the value passed by ajax:

Ajax can be used to implement interaction between non-refreshing data. The following is an example code that receives ajax passed values for your reference.

The ajax code is as follows:

$(function (){   timestamp=0;   $("#chatform").submit(function (){     var message=$("#msg").val();     var name=$("#author").val();     var action="postmsg";     var time=timestamp;     $.post(       "backend.aspx",{         arr: message+","+name+","+action+","+time        }, function (xml){       $("#msg").val("");        addMessages(xml);      });      return false;   }) })

To $. the post method does not support passing parameters in the form of arrays. Therefore, it is passed as a string in the above jquery code. The aspx page in the background can be split as an array after receiving, the Code is as follows:

string arr = Request["arr"].ToString(); string[] myarr = arr.Split(','); string message = myarr[0]; string name = myarr[1]; string action = myarr[2]; string time = myarr[3];

Original address: http://www.51texiao.cn/jqueryjiaocheng/2015/0613/4045.html

The most original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 8328.

Related Article

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.