Incrementing Dynamic JSON Data (updated)


hi,

 

hope can help, working on advertisment banner scrolls through different messages retreived randomly php file in json format.

 

some of messages directly in php file, couple of others content comes external urls.

 

now spec i've been given 1 of values provided 1 of external urls has increment every second specified value.

 

now i've got increment working via javascript in separate php file, when move code json formatted file fails , messages dont appear did before.

 

i assume because json file linking adobe edge html5 file retreiving required data , not processing json file i.e. if visit page directly.

 

i have tried copying javascript .js file , linking in head of html5 file again doesn't seem picked up?

 

just wondering if might know way go this? trying figure way code in adobe edge because messages randomised json file guess hard hook them determine message requires in increment coding.

 

update - coding added

 

apologies not adding in before here's coding:

 

i have file (ajax.php) holds content

 

<?php

$num = rand (1,5);

 

class xmltojson {

 

         public function parse ($url) {

 

                 $filecontents= file_get_contents($url);

 

                 $filecontents = str_replace(array("\n", "\r", "\t"), '', $filecontents);

 

                 $filecontents = trim(str_replace('"', "'", $filecontents));

 

                 $simplexml = simplexml_load_string($filecontents);

 

                 $json = json_encode($simplexml);

 

                 return $json;

 

         }

 

}

 

switch ($num)

{

    case 1:

 

        $jsone = xmltojson::parse("http://www.microgaming.co.uk/pokerfeeds/webserviceviewonline.asmx/viewonlinexml");

 

        $jsond = json_decode($jsone, true);

 

        $totalplayers = $jsond['global']['@attributes']['totalplayers'];

 

        $filledseats = $jsond['global']['@attributes']['filledseats'];

 

        echo json_encode('<h2>total player count</h2> ' . $totalplayers . ' players online');

 

        break;

 

    case 2:

 

        $jsone = xmltojson::parse("https://mppv2valueadds3.valueactive.eu/mpp_badbeatfeed/default.aspx");

 

        $jsond = json_decode($jsone, true);

 

        $name = $jsond['data']['struct']['var']['@attributes']['name'];

 

        $initial = $jsond['data']['struct']['var']['struct']['var'][0]['number'];

 

        $increment = $jsond['data']['struct']['var']['struct']['var'][1]['number'];

 

        echo json_encode('<h2>bad beat jackpot</h2> &pound;' . $initial);

 

        break;

 

    case 3:

        echo json_encode('<h2>the first online poker network</h2> offer real play poker on android mobile devices.');

 

        break;

    case 4:

        echo json_encode('<h2>the first online poker network</h2> offer fast-fold poker variant, blaze.');

 

        break;

    case 5:

        echo json_encode('<h2>the first online poker network</h2> management board, created in 2011.');

 

        break;

}

?>

 

this file read adobe edge code (below):

 

// insert code run when symbol created here

$.ajax({

    url: 'ajax.php',

    datatype: 'json',

    success: function(data) {

        sym.$("placeholderone").html(data);

    }

});

 

$.ajax({

    url: 'ajax.php',

    datatype: 'json',

    success: function(data) {

        sym.$("placeholdertwo").html(data);

    }

});

 

$.ajax({

    url: 'ajax.php',

    datatype: 'json',

    success: function(data) {

        sym.$("placeholderthree").html(data);

    }

});

 

which when published, looks this:

 

http://www.manninmedia.co.im/micro/logo-test.html

 

all looks , animates well, need bad beat jackpot value imported within case 2 in (ajax.php), need increment every second this:

 

http://www.manninmedia.co.im/micro/counter2.php

 

i have working separately in (counter2.php) file javascript:

 

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head>

<meta content="text/html; charset=utf-8" http-equiv="content-type" />

<title>untitled 1</title>

</head>

 

<body onload="incrementnumber()">

 

<?php

 

class xmltojson {

 

         public function parse ($url) {

 

                 $filecontents= file_get_contents($url);

 

                 $filecontents = str_replace(array("\n", "\r", "\t"), '', $filecontents);

 

                 $filecontents = trim(str_replace('"', "'", $filecontents));

 

                 $simplexml = simplexml_load_string($filecontents);

 

                 $json = json_encode($simplexml);

 

                 return $json;

 

         }

 

}

 

 

        $jsone = xmltojson::parse("https://mppv2valueadds3.valueactive.eu/mpp_badbeatfeed/default.aspx");

 

        $jsond = json_decode($jsone, true);

 

        $name = $jsond['data']['struct']['var']['@attributes']['name'];

 

        $initial = $jsond['data']['struct']['var']['struct']['var'][0]['number'];

 

        $increment = $jsond['data']['struct']['var']['struct']['var'][1]['number']; ?>

 

        <script>

 

        var number = <?php echo $initial ?>  // put initial value here

 

        function incrementnumber() {

            number += <?php echo $increment ?> // can increment here

            var result=math.round(number)

            document.getelementbyid('counter').innerhtml = result;

        }

 

        // run incrementnumber() every second (interval in ms)

        setinterval(incrementnumber, 1000);

 

        </script>

 

        <?php echo json_encode('<h2 style="float:left">bad beat jackpot</h2> &pound;'); echo '<span id="counter"></span>'; ?>

 

 

 

</body>

 

</html>

 

i wish combine 2 bad beat jackpot value increments on animated banner, efforts have been in vain.

 

i have thought applying increment animation in adobe edge somehow, how hook case 2 in ajax.php??

 

can please me?

 

 

thanks



More discussions in Edge Animate CC


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account