eldan88 Posted January 31, 2014 Share Posted January 31, 2014 Hey guys. I am new to using javascript with ajax. I want to get my hands dirty using javascript and ajax before moving on to jquery... I am trying to request a simple txt document, but my console.log is keep giving me the following.. Uncaught InvalidStateError: Failed to execute 'send' on 'XMLHttpRequest': the object's state must be OPENED. request.onreadystatechange Any idea on how to correct this? Below is my code. var request = new XMLHttpRequest(); request.open('GET', 'data.txt', true); request.onreadystatechange = function() { if((request.readyState === 4) && (request.status === 200)) { request.send(); console.log(request); document.write(request.responseText); } } request.send(); Link to comment https://forums.phpfreaks.com/topic/285816-need-help-making-a-simple-requestnewbie-question/ Share on other sites More sharing options...
eldan88 Posted January 31, 2014 Author Share Posted January 31, 2014 Never mind! I solved the issue! Link to comment https://forums.phpfreaks.com/topic/285816-need-help-making-a-simple-requestnewbie-question/#findComment-1467252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.