First type: Get Pass
Front-end Ajax GET Pass: That is, after the requested address with parameters, URL address length is displayed, security is low
Background receive: request.querystring["parameter name"]!
For example:
function Loadbar (ID) {
var project = ID;
var month = $ ("#txtMonth"). Val ();
$.ajax ({
Type: "GET",
Async:false,
URL: ' getprojectscore.aspx?project= ' + project + ' &month= ' + month,
DataType: ' JSON ',
Beforesend:function () {
},
Success:function (msg) {
if (msg) {
OptionBar.xAxis.categories = eval (msg.projectscore.orgname);
Optionbar.series = eval (msg.projectscore.series);
var t = eval ("(" + subtitle + ")");
Optionbar.subtitle = T.subtitle;
Chart = new Highcharts.chart (Optionbar);
}
},
Error:function () {
Alert (' Wrong! ');
}
});
Second type: Post Pass 2.1 string as parameter Pass
That is, the passed arguments are passed in the form of a string. Datatype= "Text";
Foreground Ajax POST Delivery: A request to submit the form data to the server, where the data to be submitted is in the entity behind the information header.
Background receive: request.form["parameter name"]
For example:
$ ("Input[name=returnfile]"). Click (function () {
var Returnflag = $ (this). Val ();
var guid = $ (this). Prev (). html ();
$.ajax ({
Type: "POST",
Async: "false",
URL: "Returndata.aspx",
Data: "flag=" + Returnflag + "&guid=" +guid+ "",
Success:function () {
}
});
})
Background receive:
String flag=request.form["flag"];
String guid=request.form["GUID"];
2.2 JSON as a parameter pass
That is, the passed arguments are passed as a JSON string. Datatype= "JSON";
Foreground Ajax POST Delivery: A request to submit the form data to the server, where the data to be submitted is in the entity behind the information header.
Background receive:
StreamReader reader=new StreamReader (Request.inputstream);
String str = reader. ReadToEnd ();
For example:
$ ("Input[name=returnfile]"). Click (function () {
var Returnflag = $ (this). Val ();
var guid = $ (this). Prev (). html ();
var str = "{' Flag ': '" + Returnflag + "', ' GUID ': '" + GUID + "'}";
var json = eval ("(" + JSON + ")"); 
$.ajax ({
type: "POST",  
Async: "false",  
URL: "khdf_returndata.aspx",
dataType: "JSON"
Data:json,
Success:function () {
}
});
})
Background receive:
StreamReader reader=new StreamReader (Request.inputstream);
String str = reader. ReadToEnd ();
After reading Newtonsoft do JSON processing
2.3 JSON as a parameter pass
$ (function () {
$ ("#btnLogin"). Click (function () {
var username = $ ("#txtUserName"). Val ();
var password = $ ("#txtPassword"). Val ();
var paras = "Username=" + username + "&password=" + password;
Alert (paras);
var data = {
Username: $ ("#txtUserName"). Val (),
password:$ ("#txtPassword"). Val ()
}
$.post ("Home/checklogin", data, function (data) {
alert (data);
})
})
})
If you follow 2.2post. You must add: ContentType: "Application/json"
Background receive:
[HttpPost]
Public ActionResult checklogin (string username,string password)
{
String name = Username;
string pwd = password;
return View ();
}
Turn from the @ home after the fight
GET POST Transmit value and receive case