So, the Internet to find a bit, with another way of writing settimeout ("fun (" + parameter +) ", 1000), or not, but the above wording in the Transfer form form of the textarea is possible, such as HML is this:
Copy Code code 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.txtara.value); />
</div>
</form>
</div>
</div>
</body>
in JS I can write like this:
SetTimeout ("Doajax (Document.sform.txtara.value)", 1000);
However, once you pass the other parameters or object parameters, the method provided online is to rewrite the function.
After research and practice, I have improved the method, we can refer to the reference, I just according to my personal needs, other circumstances I can not guarantee, please advise!
Copy Code code 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.txtara.value, this); />
</div>
</form>
</div>
</div>
</body>
JavaScript:
Copy Code code 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 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.txtara.value,document.all[" +obj.sourceindex+ "])", 100;//There's a line.
}
In this way, I solved the problem of object parameter transmission, and finally want to say, can have a better solution please make comments, I am willing to learn with like-minded people!