XML Http Requests (AJAX) allows you to send and receive data from external files within your Javascript code without refreshing the page or re-running your script.
In this video we look at how to create a request and then download the data, inserting it into the HTML body.
For your reference:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
Follow me on Twitter @dcode
If this video helped you out and you’d like to see more, make sure to leave a like and subscribe to dcode!
Original source
23 responses to “Learn XML HTTP Requests in JavaScript | AJAX Tutorial”
UPDATE:
Learn how to use AJAX to load data from an external file straight into your HTML tables:
https://www.youtube.com/watch?v=12tjh_6xL2M
amazing simple to the point.
great introduction.
i had zero knowledge before the video
after it i googled for some other videos , and it was simple after your.
Thanks man 🙂
i keep getting this error:
index.html:30 Access to XMLHttpRequest at 'file:/…./dom.txt' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Any idea what I'm doing wrong?
Hi, nice video. I did exactly what you did and I get the below error. What do you think is the issue?
mexico.js:29 Access to XMLHttpRequest at 'file:///C:/Users/imedi3/Documents/Web%20Reports/Mexico%20Triggers/prueba.txt' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
(anonymous) @ mexico.js:29
I ran the same code on my file system and i get a CORS error. How can i resolve this issue?
can someone kill me pls ?!!
why this shit doesn't work with me !!!!!!!!!!
https://stackoverflow.com/questions/56744800/why-alert-didnt-work-in-a-http-onload-from-an-xmlhttprequest
Thank you for this video very much. It fits very well when you read a little bit of the W3Schools page and I was still a little confused but you cleared all of that up and I thank you for that. I also believe in your xhr.readystatechange function you can use this.readystate and this.status instead of xhr.readystate or xhr.status. Thank you for your help though.
I'm trying to finish watching but your pretentious SUPER-DUPER tactile feedback , "I'm a real programmer", keyboard is annoying as $h!t3. You people think you're superior because your keyboard requires a million JOULES to type one letter. Terrible
Good tutorial
What are the 2 links at the top? What is Youtube.local? I've tried googling it but nothing's coming up conclusive
Thank you for sharing the video!
I use same code as you said but I got error code related to CORS, it said "Access to XMLHttpRequest …from origin 'null' has been blocked by CORS policy"
https://www.w3schools.com/xml/ajax_intro.asp i can read too
Hey Dom , do you like to use the DOM ?
Perfect :d
What is the editor, please?
Great video. Thanks a lot. I like your teaching style. Keep up the good work.
Awesome video! 😀
Thanx for making the video, I really needed this explanation.
Good but you are no longer allowed to make xhr requests sync (false parameter). See console error infor in chrome for more information. We have to use Worker.class to do this. Im not sure how to solve it. Would be great to get another video about it.
Very Great Video! Codecademy doesn't even go into any detail or depth as for the purpose for the actual commands used. Really helped understanding the process more. Thanks for the great content and tutorial man! 🙂
Thank you helped me out a lot!
Amazing explanation 😀
Firstly thanks for the video. To me though, it seems more logical to put the xhr open and send lines before the function. I have to admit I’ve never seen it done this way. But wouldn’t it make more sense to make the request, send it, then run the function to check all is okay and display? Of course it doesn’t matter as the function can sit anywhere, but in terms of logical programming wouldn’t that way round make more sense?