No, I think its correct as the code is working in Firefox.
I’m guessing that the OP is testing locally and Chrome won’t load files locally because of cross domain issues. You can set a flag on your local browser if you need to test.
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.loadDoc @ test1.html:26
The code should work online ok or on a local (wamp) server etc.
If you did read it then it may help if you can confirm if you are only testig locally or not and that you have also tested online and get the same results.
The more information you provide the easier it will be to get an answer to the problem
The same code copied locally will not work on Chrome due to origin restrictions as already mentioned in my previous post. It will produce this error in Chrome:
2ajax-test.html:21 XMLHttpRequest cannot load file:///C:/Users/paulo/Desktop/websites/testing/ajax_info.txt. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
It will work fine in Firefox but not locally on Chrome.
I don’t know how else to say it
Copy your file to an online server and then they will work in Chrome just like the w3cschools site.