0

i need take XML data from this URL : http://45.119.203.114:8888/xmltv.php?username=epg&password=epg to parse EPG data

i have try with Javascript And PHP but it doesn't work

this my code

Javascript

var xmlHttp = new XMLHttpRequest();

    xmlHttp.open( "GET", 'http://45.119.203.114:8888/xmltv.php?username=epg&password=epg'); // false for synchronous request
    xmlHttp.responseType = 'document';
    xmlHttp.setRequestHeader('Accept', 'application/xml');

    xmlHttp.onload = function () {
        if ( xmlHttp.readyState == 4  && xmlHttp.status == 200 ) {
            console.log(xmlHttp.responseXML);
        }
    }
    xmlHttp.send();

the result in my javascript code is always No 'Access-Control-Allow-Origin'

and this my PHP code

$path = 'http://tvku.live:8888/xmltv.php?username=epg&password=epg';



    $xml=simplexml_load_file($path);
            $me = "sub-title";
            foreach($xml->programme as $item){
                echo "Start : " .date("G:i d.m.Y", strtotime(substr($item["start"], 0,  -6))) . '<br>';
                echo "End : " .date("G:i d.m.Y", strtotime(substr($item["stop"], 0,  -6))) . '<br>';
                echo "Channel : ".$item["channel"]. "<br>";
                echo "Title : ".$item->title. "<br>";
                echo "Info : ".$item->$me. "<br>";
                echo "Description : ".$item->desc. "<br>";
                echo "<br>";
            }

there is no result in my php code, before in my PHP code i have try using CURL to get data but not that works too

please ask for your help, thanks

1
  • 1
    different domains, CORS problems Commented Jun 3, 2019 at 10:04

1 Answer 1

3

the result in my javascript code is always No 'Access-Control-Allow-Origin'.

Well, the error is pretty clear the backend is not allowed to answer to CORS request if you own the backend you have to allow CORS (take a look to this documentation).
Otherwise, you need to ask the backend owner to allow the CORS requests.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.