+ 2

[SOLVED] How to read the content of an external text file

How to read external content of a text file to work with as an array or variable? (Something like file_gets_content in PHP) I have 2048 words in my text file on 2048 lines. ((I do not want them converted into a internal array and implement it in my code, but leave them as it is otherwise it takes to much space.. )) I have the .txt file external in my Dropbox and want to read the content with JavaScript. How?! https://www.dropbox.com/s/7of3dozytnlq1tt/words.txt?dl=0

11th Sep 2018, 11:23 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
6 Respostas
+ 3
Remember that JS is client side. You can try using iframe (HTML) or try using AJAX.
12th Sep 2018, 4:44 PM
Alexander Santos
Alexander Santos - avatar
12th Sep 2018, 8:46 PM
Alexander Santos
Alexander Santos - avatar
+ 2
External link, but this was one of projects i made using AJAX via GET method. https://codepen.io/ronkiro/pen/QmmPGM You can use it as an example.
13th Sep 2018, 1:33 AM
Alexander Santos
Alexander Santos - avatar
+ 1
Alexander Santos, I did some reseach to AJAX http requests and found that AJAX is a very good for those tasks. Thanks for that👍. I made me some code to read the content of the text file but I get an error. CORS policy is blocking the GET request.. So there is no connection at all after debugging the code... How to solve the request blocking? Have a look at the console log after button click: https://code.sololearn.com/WPp9ZQQThP2b/?ref=app
12th Sep 2018, 7:39 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
+ 1
ODLNT & Alexander Santos, Thank you both for helping me out with AJAX and providing extended information about this subject!! excellent! I understand now it had nothing to do with my script but with the server I'll try to get requests from. Since I need to work with API credentials at Dropbox I wont implement them in SL. Therefore, Socrata is an very good option to understand more of the basics about API's and the server requests that AJAX provides. Will get more into this right now!👍
13th Sep 2018, 11:56 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
0
ODLNT, Thanks👍
12th Sep 2018, 11:25 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar