When multiple values are transmitted using the post method of jquery, the backend page can receive values in array format.
As shown below
<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 ){
// Clear the content in the message text box
$ ("# Msg"). val ("");
// Call the function for parsing xml
AddMessages (xml );
});
Return false;
})
})
</Script>
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];
In this way, the corresponding value is obtained.
From birch of Autumn