Turn? Example of jquery Ajax in C # (i)

Source: Internet
Author: User

Target: Enter two parameters on the ASPX page and upload to the background. CS code, in the no refresh display to the foreground

Here is the first instance of my Ajax asynchronous pass-through value

1. Foreground HTML code:

2. Background code:

Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;namespace ajaxdemo{public    partial class Demo1:System.Web.UI.Page    {        protected void Page_Load (object sender, EventArgs e)        {        } The        //type method must be post, the method must be static, and the method declaration is prefixed with the attribute [ System.Web.Services.WebMethod ()], the number of arguments passed should also be the same as the parameters of the method.        [System.Web.Services.WebMethod ()] public        static string Ajaxmethod (String param1, String param2)        {            return "Parameter 1 is:" +param1+ ", Parameter 2 is:" +PARAM2;}}    }

3. Operating effect:

4. Enter the data and click Submit:

5. Note:

The 1th step contenttype: "Application/json; Charset=utf-8 "This sentence must not be less! Not set this, JSON is not back to return

Of course, you can also write the following post-value format:

var data={"name": "Tom", "Age": "};var" url= "Xxx.ashx" $.post (Url,data,function () {alert ("ok!")});

Turn? Example of jquery Ajax in C # (i)

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.