Показать сообщение отдельно
  #2 (permalink)  
Старый 16.09.2012, 01:15
что-то знаю
Отправить личное сообщение для devote Посмотреть профиль Найти все сообщения от devote
 
Регистрация: 24.05.2009
Сообщений: 5,176

Сообщение от Dim@ Посмотреть сообщение
function Ajax () {
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
Давно пора забыть уже про этот способ.

Достаточно делать так:
var ajax = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
ajax.open("GET", "test.xml", true);
ajax.onreadystatechange = function() {
    if ( ajax.readyState == 4 ) {
        var status = ( ajax.status === 1223 ) ? 204 :
            ( ajax.status === 0 && ( self.location || {} ).protocol == 'file:' ) ? 200 : ajax.status;

        if ( status >= 200 && status < 300 || status === 304 ) {
            alert( ajax.responseText ); // срабатывает
        }
    }
};
ajax.send( null );
__________________
хм Russians say завтра but завтра doesn't mean "tomorrow" it just means "not today."
HTML5 history API рассширение для браузеров не поддерживающих pushState, replaceState
QSA CSS3 Selector Engine
Ответить с цитированием