日期:2014-05-18  浏览次数:20731 次

ajax,如何传参数?
ajax,如何传参数?

JScript code
function SendQuery(url, name)
{
    Initialize();
    if(req!=null)
    {
        req.onreadystatechange = Process;
        req.open("GET", url, true);
        req.send(null);
    }
}
function Process()
{
    //alert(url);如何将url传到这里?
}


------解决方案--------------------
Ajax 给 XMLHttpReq.onreadystatechange传递参数 
通过:
xmlhttp.onreadystatechange= function(){xx(123)};
or
xmlhttp.onreadystatechange= new Function("xx(123)");
就可以了。

m=document.getElementsByName("text8");
v=m[i];
XMLHttpReq.onreadystatechange=function(){proce(v)};
----------------------------------------------
function proce(v)
{
if(XMLHttpReq.readyState==4)

if(XMLHttpReq.status==200)
{
var res=XMLHttpReq.responseXML.getElementsByTagName("content")[0].firstChild.data;
v.value=res;
}
else
{
v.value='....';
}
}
}