When you pass multiple values in jquery post, you can receive them in an array form in the background page
as shown below
Copy Code code as follows:
<script type= "Text/javascript" >
$ (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) {
Empty the contents of the Message text box
$ ("#msg"). Val ("");
Calling a function that parses XML
Addmessages (XML);
});
return false;
})
})
</script>
Passing parameters as an array is not supported in $.post, so it is passed as a string in the jquery code above, and the ASPX page in the background can be split in the form of an array after it is received, as follows
Copy Code code 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];
So we can get the corresponding value.