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)