+ 6

Can a person use the getHttpObject on SoloLearn?

Please share any codes where this is done. I am trying to learn to get data from a server. It works on w3-schools but not in the coding playground.

5th Nov 2018, 9:00 AM
Ryan Els
Ryan Els - avatar
6 Antworten
+ 3
The problems are 2: - The "customers.js" is a path and in this case is relative to current page (filesystem on android, sl server on web SL) but you want a specific script "customers.js", that on w3 server and in particular at url "https://www.w3schools.com/w3js/customers.js" - Unfortunatly, w3 server dont send a cross-origin allowing header and this DONT allow to you to load that script in other servers but you can resolve use cors-anywhere (or similar services) At end, try to replace the call to w3.getHttpObject with: w3.getHttpObject("https://cors-anywhere.herokuapp.com/https://www.w3schools.com/w3js/customers.js", myFunction);
5th Nov 2018, 9:54 AM
KrOW
KrOW - avatar
+ 5
KrOW Thanks. I will give it a try 👍. Thanks for answering.
5th Nov 2018, 9:58 AM
Ryan Els
Ryan Els - avatar
+ 3
Below is the code example. I know the problem has to do with the .js file that sits on the w3-schools server. But how can I create my own example and access some code or stylesheet from this server?
5th Nov 2018, 9:11 AM
Ryan Els
Ryan Els - avatar
5th Nov 2018, 9:15 AM
Ryan Els
Ryan Els - avatar
+ 3
Ryan Els You are welcome 👍👍👍
5th Nov 2018, 9:58 AM
KrOW
KrOW - avatar