So, I searched online and used another writing method setTimeout("fun(" parameter ")", 1000), but it still didn't work. However, the above writing method is OK when passing the textarea of the form form. For example, hml is like this:
In js I can write like this: setTimeout("doAjax(document. sform.txtara.value )", 1000);
But once you want to pass other parameters or object parameters, you have to rewrite this function according to the methods provided on the Internet.
After research and practice, I have improved the method myself. You can refer to it. I only base it on my personal needs. I cannot guarantee other situations. Please give me your advice!
JavaScript:
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; // Mainly this 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);//Also This line
}
In this way, I solved the problem of object parameter passing. Finally, I would like to say that if you have a better solution, please leave a comment. I am happy to cooperate with like-minded people. study!