javascript - AJAX response problem -
javascript - AJAX response problem -
i've got function:
function ajax() { var xmlhttp, onready, open, response; if(window.xmlhttprequest) { this.xmlhttp = new xmlhttprequest(); } else { this.xmlhttp = new activexobject("microsoft.xmlhttp"); } this.onready = function(onready) { this.xmlhttp.onreadystatechange = function() { if ( this.xmlhttp.readystate == 4 && this.xmlhttp.status == 200) { onready.call(); } } }; this.open = function(_filename, _method) { this.xmlhttp.open(_method, _filename, true); this.xmlhttp.send(null); }; this.response = function() { homecoming this.xmlhttp.responsetext; }; } function rc() { var ajax = new ajax(); ajax.onready(function() { document.getelementbyid("comments").innerhtml = ajax.response(); }); ajax.open("ab.php","get"); } rc();
and request sent fine, can't extract response.
it shows readystate doesn't exist in xmlhttp object.
when run code getting "this.xmlhttp undefined" line:
if ( this.xmlhttp.readystate == 4 && this.xmlhttp.status == 200)
you within of xmlhttp object. line should be:
if ( this.readystate == 4 && this.status == 200)
this should prepare error.
javascript ajax
Comments
Post a Comment