+ 1
Can we link a Variable Arrays from external source?
Is it possible if i write some sort of variable arrays in a txt file and save it on some cloud storage and call it into JS script? if yes, then how do i do that? thanks all đ
10 Answers
+ 3
Surely you can. But the extension of the file must be 'js'. You can write any valid javascript code in a file. Then upload it to dropbox or any other hosting site. Therefore, you can now load the script using the 'script' tag.
+ 3
Where is your attempt? Please try to do that, then can you more quickly learn the language and come to a solution of your task.
+ 2
Arb Rahim Badsa you're almost right, except for a tiny details: file extension must be 'js' or also often 'json' if file is served "automatically" (then the MIME type of the send file is set according to its extension), but if you handle it "manually" you could serve file with any extension you want since you set the correct js MIME type for the Http request response ;)
+ 2
Arb Rahim Badsa on server side with almost any web framework, you could set response headers as you want, among wich information is the MIME type of the file you send to client side (used by browser to know what kind of ressource it is and what to do with it, not relying only on the file extension ;))
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
+ 1
Thanks Arb Rahim.. actually I tried it once before but not working, will give another shot and see, maybe i will paste the code here as well later đ
+ 1
Sure, you can attach the code here. Perhaps I'll then be able to show you a demo.
+ 1
Ohmyyy... It works now đ
thanks you guys for your guidance.. I upload my variable js file into GDrive.. thanks again! đđ
https://code.sololearn.com/WhjXN1IRQky0/?ref=app
+ 1
visph That was indeed a good information. But what do you actually mean by handling 'manually'?
+ 1
You can but in HTML add script with array first and then script which uses this array
0
Ok Sir, thanks so much! đ, I still have alot more to study in.. wish me succeed.. đLoL