Requesting Live Data with Ajax

This section covers the Meteobridge PRO, PRO2, NANO SD, Raspberry Pi and VM platforms exclusively

Moderator: Mattk

Post Reply
Thomas_S
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: Thu Mar 05, 2020 5:51 pm

Requesting Live Data with Ajax

Post by Thomas_S »

Hi everybody,
I'm using a Davis 6152EU Vantage Pro 2 weather station and the meteobridge PRO red to receive the weatherdata. I want to display the data on a LED Wall using a Digital Signage Player. The weather data should be picked up by the player via GET Request. The Signage Player and the meteobridge are in the same network with fixed IPs. The HTML widget on the player now tries to fetch the data via an ajax request. The following error message is displayed:

"Access to XMLHTTPRequest has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requestet resource"

Can someone tell me what the correct ajax request should look like or is there an alternative?

Thank you in advance for your help!
weatherist34
Platinum Boarder
Platinum Boarder
Posts: 1693
Joined: Tue Mar 28, 2017 6:57 am

Re: Requesting Live Data with Ajax

Post by weatherist34 »

Thomas_S wrote: Mon Mar 09, 2020 3:55 pm Hi everybody,
I'm using a Davis 6152EU Vantage Pro 2 weather station and the meteobridge PRO red to receive the weatherdata. I want to display the data on a LED Wall using a Digital Signage Player. The weather data should be picked up by the player via GET Request. The Signage Player and the meteobridge are in the same network with fixed IPs. The HTML widget on the player now tries to fetch the data via an ajax request. The following error message is displayed:

"Access to XMLHTTPRequest has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requestet resource"

Can someone tell me what the correct ajax request should look like or is there an alternative?

Thank you in advance for your help!
if its residing on a apache server this might help if its on a different server platform then a google search on No 'Access-Control-Allow-Origin' might be rewarding.

im only familiar with apache

if you access to the .htaccess file then making sure the apache mod_headers are enabled


inserting

<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
</IfModule>

most common error of this method not working is the server needs restarting which is normally beyond the end users reach if it is a hosted package or the mod_headers are disabled which a phpinfo can reveal
note the word Ifmodule is wrapped and basically means if present,enabled etc

there are other lines you can insert for things like js,fonts,images etc..

hope its of some use ..brian
Simple Update February 2023 for Weather34 Aurora MKII
https://www.mediafire.com/file/jk4lj3mq ... 2.zip/file

Weather34 Master Download Aurora MKII
https://download.meteobridge.com/files/Weather34.zip
Post Reply