ссылка http://127.0.0.7 думаю мало поможет делу ... а код ниже (отрезаны вспомогательные функции)
Код | var req; // Конструктор. function DDList(obj_value, obj_name, obj_id, obj_class) { this.obj_value = obj_value; this.obj_name = obj_name; this.obj_id = obj_id; this.obj_class = obj_class; this.popup = "none";
// для "родного" XMLHttpRequest if (window.XMLHttpRequest) { req = new XMLHttpRequest(); // для версии с ActiveX } else if (window.ActiveXObject) { var aVersions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"]; for (var i = 0; i < aVersions.length; i++) { try { req = new ActiveXObject(aVersions[i]); } catch (oError) { if (i == aVersions.length) throw new Error("Ваш броузер не поддерживает объект XMLHttp!"); } } } this.old_value = (this.obj_value!=null?this.obj_value:""); // --------------------------------------------------------------------------- this.get_suggest = function() { this.get_data("/ddlist.php?suggest=" + document.getElementById(this.obj_id).value); } // --------------------------------------------------------------------------- this.get_value = function() { selfa = this; // ЗАВОДИМ ТАЙМЕР setTimeout( function(){ selfa.get_value();}, 1000 ); if (this.old_value != document.getElementById(this.obj_id).value) { this.old_value = document.getElementById(this.obj_id).value; this.get_suggest(); } } // --------------------------------------------------------------------------- this.show_popup = function(value) { document.getElementById('DDList_Popup_' + this.obj_id).innerHTML = "value"; document.getElementById('DDList_Popup_' + this.obj_id).style.display="block"; } // --------------------------------------------------------------------------- this.get_data = function(url) { req.onreadystatechange = this.have_data; // М... ВОТ ЗДЕСЬ ПОХОЖЕ И ПРОБЛЕМА...(НАДО ПЕРЕДАТЬ НЕ ТОЛЬКО ФУНКЦИЮ, НО И ОБЪЕКТ?) req.open("GET", url, true); req.send(null); } // --------------------------------------------------------------------------- this.have_data = function() { if (req.readyState == 4) { if (req.status == 200) { //eval(req.responseText); this.show_popup(req.responseText); // ЗДЕСЬ ОШИБКА!!! } else { alert("Не удалось получить данные:\n" + req.statusText); } } } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- document.write('<div class="DDList_Popup" style="display:' + this.popup + '" id="DDList_Popup_' + this.obj_id + '"></div><input type="text" ' + (this.obj_value!=null?('value="' + this.obj_value + '" '):' ') + (this.obj_name!=null?(' name="' + this.obj_name + '" '):' ') + (this.obj_id!=null?(' id="' + this.obj_id + '" '):' ') + (this.obj_class!=null?('class="' + this.obj_class + '" '):' ') + '/>'); this.get_value(); }
|
|