Код | <script language="Javascript"> function miniAjax() { this.xmlhttp = function() { return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); } this.send = function(u, f, m, a) { this.xmlhttp.open(m,u,true); this.xmlhttp.onreadystatechange = function() { if (this.xmlhttp.readyState == 4) { if (this.xmlhttp.status == 200) { f(this.xmlhttp.responseText); } } } if (m == 'POST') { this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } this.xmlhttp.send(a) } this.get = function(u,f,m,a) { this.send(u,f,m,a); } }
var obj = new miniAjax(); function bubu(g) { alert(g); } </script> <span onclick="obj.get('bu.html', bubu,'GET', null);">test</span>
|
Почемуто ругается на this.xmlhttp.open is not a function |