It is currently 24 Jun 2017, 09:49



HTML producer BUG or NOT ?

Videos, graphics, Flash templates – how to create and play them using CasparCG

Moderators: Macey, Jonas Hummelstrand, didikunz

HTML producer BUG or NOT ?

Postby maurice78 » 16 Aug 2016, 16:02

Hi all

Is this good behavior from the HTML producer or not ?
when i use this codesnip in a HTML template it does not work
Code: Select all
         function readXML(){
          var XHTTP;
          XHTTP = (window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
          XHTTP.open("get", XMLurl, true);
          XHTTP.send();
          XHTTP.onreadystatechange = function() {
            if (XHTTP.readyState == 4 && XHTTP.status == 200) {
              XMLrtn = XHTTP.responseText;
              JSONrtn = XML2jsobj(XHTTP.responseXML.documentElement);
              procdata();
              }
            };
        }


when i serve the template from a http server it does work.
Code: Select all
PLAY 1-10 [HTML] "http://127.0.0.1:8888/RANK.html"

when i load it as a file it does not work.
Code: Select all
PLAY 1-10 [HTML] "file:///Volumes/HD1/templates/RANK.html"


it seams the XHTTP.status is not set because when i forget about this in the if statement it starts to work.

grt
Maurice
maurice78
 
Posts: 122
Joined: 28 May 2013, 21:51

Re: HTML producer BUG or NOT ?

Postby balte » 17 Aug 2016, 14:33

Hi,

This is intended behaviour.
Please look into same origin policies. You can't do http requests from a file to websites who don't have a same-origin-policy set to all.

The XHTTP.status is set, it just doesn't return 200.
CasparCG enthusiast and broadcast geek - Sometimes, I do get payed for this stuff.
User avatar
balte
 
Posts: 264
Joined: 24 Jan 2015, 16:23
Location: The Netherlands, Goeree Overflakkee

Re: HTML producer BUG or NOT ?

Postby maurice78 » 22 Aug 2016, 13:26

Thanks Balte

so i guess it is save to do
Code: Select all
if (XHTTP.readyState == 4)


grt
Maurice
maurice78
 
Posts: 122
Joined: 28 May 2013, 21:51

Re: HTML producer BUG or NOT ?

Postby balte » 22 Aug 2016, 14:36

Status codes can be any of these: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

You should be handling these appropriately.
CasparCG enthusiast and broadcast geek - Sometimes, I do get payed for this stuff.
User avatar
balte
 
Posts: 264
Joined: 24 Jan 2015, 16:23
Location: The Netherlands, Goeree Overflakkee


Return to Content

Who is online

Users browsing this forum: No registered users and 5 guests