javascript 函数参数需要定义吗
2个回答
展开全部
不需要定义,直接使用参数即可,但类型要对应。
举个例子:
function ajax(url,fnSucc,fnFaile)
{
if (window.XMLHttpRequest)
{
var oAjax = new XMLHttpRequest();
}
else
{
var oAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
oAjax.open('GET', url, true);
oAjax.send();
oAjax.onreadystatechange = function () {
if (oAjax.readyState == 4)
{
if (oAjax.status == 200)
{
fnSucc(oAjax.responseText);
}
else
{
if (fnFaile)
{
fnFaile(oAjax.status);
}
}
}
};
}
举个例子:
function ajax(url,fnSucc,fnFaile)
{
if (window.XMLHttpRequest)
{
var oAjax = new XMLHttpRequest();
}
else
{
var oAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
oAjax.open('GET', url, true);
oAjax.send();
oAjax.onreadystatechange = function () {
if (oAjax.readyState == 4)
{
if (oAjax.status == 200)
{
fnSucc(oAjax.responseText);
}
else
{
if (fnFaile)
{
fnFaile(oAjax.status);
}
}
}
};
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询