I want to send an Ajax request for html page:

//Объект для работы с веб-сервером var xmlHttp = false; function ShowWinter(event){ event.preventDefault(); createObject(); //Создание URL подключения(Адрес файла обработчика) var url = "file:///Z:/home/lb/js/ajax.js"; //Открываем соединение с сервером xmlHttp.open("GET",url,true); //Устанавливаем функцю, которая выполнится после ответа сервера xmlHttp.onreadystatechange = updatePage; //Передаем запрос xmlHttp.send(null); } function updatePage() { if(xmlHttp.readyState == 4){ //Получаю html страницу var response = xmlHttp.????; //Добавление ответа в форму $('showDiv').on(response); } } //Функция для создания объекта для работы с веб-сервером function createObject() { //Создание объекта для общения с веб-сервером для браузеров Windows try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { xmlHttp = false; } } //Создание объекта для общения с веб-сервером для остальных браузеров if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); } } 

file ajax.js file for processing requests. How to send a page to the client in response. Ajax is familiar with a couple of hours.

    1 answer 1

    To get a response from the server, you need to access the responseText property of the XMLHttpRequest object.

     var response = xmlHttp.responseText 

    But if you use jQuery , then write already on it

     function ShowWinter(event) { event.preventDefault(); $.ajax({ url: "file:///Z:/home/lb/js/ajax.js"; mathod: "GET"; dataType: "html"; // or "text" success: function(data) { $('#showDiv').html(data); }; }); } 
    • It turns out the creation of a request, but how to process a request in ajax.js? - bsuart
    • Understood, create a php file that will send data via echo - bsuart