There is the following javascript on my web page:
var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://www.google.com', true); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { alert('resp received, status:' + xhr.status + ', responseText: ' + xhr.responseText); } }; xhr.send(null);
runs and ends w / readyState of 4, state 0 and empty responseText and responseXML. I know that it really sends a b / c request, which I tried to send xhr to the server on my machine, and the server really responds. why am I not getting anything in responseText? is there something to do with the fact that xhr is going to another server?
when I open the js debugger and type 'xhr' to check the object, I get the following:
XMLHttpRequest
DONE: 4
HEADERS_RECEIVED: 2
DOWNLOAD: 3
OPEN: 1
MESSAGE: 0
abort: function abort () {
addEventListener: function addEventListener () {
dispatchEvent: function dispatchEvent () {
getAllResponseHeaders: function getAllResponseHeaders () {
getResponseHeader: getResponseHeader () function {
onabort: null
onerror: null
onload: null
onloadstart: null
onprogress: null
onreadystatechange: function () {
open: open () function {
overrideMimeType: function overrideMimeType () {
readyState: 4
removeEventListener: removeEventListener () function {
responseText: "
responseXML: null
send: send () function {
setRequestHeader: function setRequestHeader () {
status: 0
statusText: ""
download: XMLHttpRequestUpload
withCredentials: false
javascript ajax
aaronstacy
source share