【发布时间】:2011-12-20 22:13:48
【问题描述】:
将参数传递给匿名 onreadystatechange 回调的普通纯 javascript(即不是 JQuery)方式是什么?
例如:
function doRequest(){
/* Get an XMLHttpRequest in a platform independent way */
var xhttp = getXmlHttpRequestObject();
var msg="show this message when done"; /* another variable to pass into callback */
/* How do I pass 'msg' and 'xhttp' into this anonymous function as locals
named 'x' and 'm'??? */
xhttp.onreadychangestate=function(x,m)
{
if( x.readyState == 4 )
{
alert(m);
}
}
/* do the open() and send() calls here.... */
}
【问题讨论】:
标签: javascript ajax