mischa.samolkaev
Продвинутый
Дата регистрации:
12.07.2012 13:00:02
Сообщений: 74
Функции:
function CreateRequest()
{
var Request =false;
if (window.XMLHttpRequest)
{
Request = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
//Internet explorer
try
{
Request = new ActiveXObject("Microsoft.XMLHTTP"
alert(0)
}
catch (CatchException)
{
Request = new ActiveXObject("Msxml2.XMLHTTP"
alert(1)
}
}
if (!Request)
{
alert(" XMLHttpRequest"
}
return Request;
}
function SendRequest(r_method, r_path, r_args, r_handler)
{
var Request = CreateRequest();
if (!Request)
{
return;
}
Request.onreadystatechange = function()
{
if (Request.readyState == 4)
{
r_handler(Request);
}
}
if (r_method.toLowerCase() == "get" && r_args.length > 0)
r_path += "?" + r_args;
Request.open(r_method, r_path, true);
if (r_method.toLowerCase() == "post"
{
Request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8"
Request.send(r_args);
}
else
{
Request.send(null);
}
}