JS get data in html file

Associate
Joined
21 Jan 2021
Posts
3
Good morning everyone.
I'm here with a big favour.
I would like someone to guide me in the right direction

In my work place i need to find solution to display data on the monitor from the website but to have certain data more simply shown than it is on the website.
I know to do so i could simply open html file in full screen and remove all the cursor/info bar ect. But the struggle is how do i get data from external url in to the html file using javascript?

For example:
I could open html file where javascript get image from external url and display certain text that is from external url.
Could you please help me to figure out how to do this? At least beggining with what to start with.
Thanks
Kind regards
Oberly
 
Associate
OP
Joined
21 Jan 2021
Posts
3
Thanks for info. Will try to look what can i get out of this. Maybe somebody else have got some sample from past to share?
 
Soldato
Joined
18 Oct 2002
Posts
14,760
Location
The land of milk & beans
Be aware that XMLHttpRequests in the client browser only work when running on the same domain. If you're trying to run this on domainA.com (or even your local machine) and make a request to domainB.com to get the information, I'm afraid it won't work unless you have control of the response coming from the domainB.com in order to include CORS headers.

In other words, what you're trying to do is absolutely possible but JS may not be the best thing to use for it.
 
Associate
OP
Joined
21 Jan 2021
Posts
3
Be aware that XMLHttpRequests in the client browser only work when running on the same domain. If you're trying to run this on domainA.com (or even your local machine) and make a request to domainB.com to get the information, I'm afraid it won't work unless you have control of the response coming from the domainB.com in order to include CORS headers.

In other words, what you're trying to do is absolutely possible but JS may not be the best thing to use for it.
Well if it's not the best option to use JS. Then could python be better solution for this?
 
Soldato
Joined
18 Oct 2002
Posts
9,783
Is your website a WordPress website? I ask because the WordPress system offers an rest api which allows you to get all the information from a page in json format. You can use java script to do a GET request of the url and return the json data for any particular page.
 
Top Bottom