So I searched the internet and used another method, setTimeout ("Fun (" + parameter + ")", 1000, however, the preceding method is applicable when passing form textarea. For example, hml is like this:
CopyCode The Code is as follows: <body>
<Div class = "Main">
<Div id = "showpane" class = "showpane"> </div>
<Div class = "textarea">
<Form method = "Post" Action = "" name = "sform">
<Textarea name = "txtara"> </textarea>
<Div>
<Input type = "Submit" name = "subt" value = "send" onclick = "doajax(sform.txt ara. Value); Return false;"/>
</Div>
</Form>
</Div>
</Div>
</Body>
In JS, I can write like this:
SetTimeout ("doajax(document.sform.txt ara. Value)", 1000 );
However, if you want to pass other parameters or object parameters, You need to rewrite this function according to the method provided on the Internet.
After research and practice, I have improved my methods. You can refer to it for reference. I only rely on my personal needs. I cannot guarantee other situations. Please give me more advice!Copy codeThe Code is as follows: <body>
<Div class = "Main">
<Div id = "showpane" class = "showpane">
</Div>
<Div class = "textarea">
<Form method = "Post" Action = "" name = "sform">
<Textarea name = "txtara"> </textarea>
<Div>
<Input type = "Submit" name = "subt" value = "send" onclick = "doajax(sform.txt ara. value, this); Return false;"/>
</Div>
</Form>
</Div>
</Div>
</Body>
Javascript: Copy code The Code is as follows: function initajax (){
VaR httprequest = NULL;
Try {
Httprequest = new activexobject ("msxml2.xmlhttp ");
}
Catch (e ){
Try {
Httprequest = new activexobject ("Microsoft. XMLHTTP ");
}
Catch (e ){
Try {
Httprequest = new XMLHttpRequest ();
}
Catch (e ){
Httprequest = NULL;
}
}
}
Return httprequest;
}
Function doajax (MSG, OBJ ){
VaR OBJ = OBJ; // This line is the main line.
Alert (obj. value );
VaR He = "He =" + MSG;
VaR ajaxrequest = initajax ();
Ajaxrequest. Open ("Post", "ABC. jsp", true );
Ajaxrequest. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded; charset = UTF-8 ");
Ajaxrequest. Send (HE );
Ajaxrequest. onreadystatechange = function (){
If (ajaxrequest. readystate = 4 ){
If (ajaxrequest. Status = 200 ){
Document. getelementbyid ("showpane"). innerhtml = ajaxrequest. responsetext;
}
Else {
Doajax (MSG );
}
}
}
SetTimeout ("doajax(document.sform.txt ara. Value, document. All [" + obj. sourceindex + "])", 100); // there is also this line
}
In this way, I solved the problem of passing object parameters. Finally, I would like to say that I would like to comment on a better solution. I would like to learn from like-minded people!