var xmlHttp = false;
var sGlobalHelpReceiverObjectId; //set in AjaxHelp
/* Создание нового объекта XMLHttpRequest для общения с Web-сервером */
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function CallServer(strUrl, strParams,strMethod,fOnUpdate)
{
// var xmlHttp = false;
if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
xmlHttp = new XMLHttpRequest();
if (xmlHttp.overrideMimeType)
{
// set type accordingly to anticipated content type
//xmlHttp.overrideMimeType('text/xml');
// xmlHttp.overrideMimeType('text/html');
}
}
else if (window.ActiveXObject)
{ // IE
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!xmlHttp)
{
var oGlobalHelpObject = document.getElementById(sGlobalHelpReceiverObjectId);
document.body.style.cursor='default';
// oGlobalHelpObject.innerHTML="AJAX not available";
alert("Data Fetch Error \nAJAX not available");
return false;
}
//AjaxToTrof("callServer
" +strMethod + "
" + strParams + "
" + xmlHttp);
// Создать URL для подключения
var url = strUrl; //"AjaxHelp.php";
// Установить функцию для сервера, которая выполнится после его ответа
xmlHttp.onreadystatechange = fOnUpdate; //updateHelpPage;
if(strMethod == "GET")
{
url = url + "?" + strParams + "&r=" + Math.random();
var oGlobalHelpObject = document.getElementById(sGlobalHelpReceiverObjectId);
// oGlobalHelpObject.innerHTML="Loading " + url;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
// Открыть соединение с сервером
if(strMethod == "POST")
{
reqTimeout = setTimeout("TrofAjaxTimeout();", 9000);
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded, charset=utf-8");
xmlHttp.setRequestHeader("Content-length", strParams.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(strParams);
//AjaxToTrof("callServer
" +strMethod + "
" + strParams + "
LEN(" + strParams.length +")
" + xmlHttp);
}
}
function TrofAjaxTimeout()
{
xmlHttp.abort;
AjaxToTrof("\n\n Server does not respond for too long.\n\n Sorry, but you probably will have to retry your request.\n");
}
function AjaxToTrof(sM)
{
var od = document.getElementById('trof_debug');
if(!od) {return;}
od.innerHTML = od.innerHTML + '\n