1

code look like this

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        function updateDiv() {

            $.getJSON('info.php?hash=<?php echo $torrent_hash; ?>', function (data) {
            }).done(function (data) {
                $.each(data, function (i, item) {
                    console.log(item.size);
                    $('#sp').html(item.size);

                });
            });
        }
        updateDiv();
        setInterval(updateDiv, 10000);

    });
</script>

where $.getJson get data from different json like which is create by $torrent_hash

and its look like for first hash value

http://localhost/final/info.php?hash=8195e4f6619ce780925d9952b358744dd81f1299

{
    "info":{
        "name":"War.on.Everyone.2016.HDRip.XViD-ETRG",
        "progress":0.02,
        "size":"706.72 MiB",
        "hash":"8195e4f6619ce780925d9952b358744dd81f1299",
        "peer":0,
        "speed":"0 Byte",
        "path":"C:\\xampp\\htdocs\\final\\download\/8195e4f6619ce780925d9952b358744dd81f1299"
    }
}

And Second Hash Value looks like http://localhost/final/info.php?hash=5a1a5f86d71f46b53a2c4719f671555a0b33940e

{
    "info":{
        "name":"BOLLYGRAM 6th EDITION (UNPLUGGED) - (2016) DJ RINK (Remix)",
        "progress":0,
        "size":"64.59 MiB",
        "hash":"5a1a5f86d71f46b53a2c4719f671555a0b33940e",
        "peer":0,
        "speed":"0 Byte",
        "path":"C:\\xampp\\htdocs\\final\\download\/5a1a5f86d71f46b53a2c4719f671555a0b33940e"
    }
}

At console its fatch Both Data at a same time like this

706.72 MiB  sp.php:188 
64.59 MiB   sp.php:188 
64.59 MiB   sp.php:142 
706.72 MiB

Here is my question when store this data to html "p" tag its show only last data 64MiB instead of both data

i use $('#sp').html(item.size); to store data

I need Output Like

 size = 760Mib than
 size = 63Mib

1 Answer 1

0
<script>


    $(document).ready(function() {
        function updateDiv(){
            $.ajax({
                type: "POST",
                url: "info.php?hash=<?php echo $torrent_hash; ?>",
                data: $(this).serialize(),
                dataType: "json",
                success: function(data) {
                console.log(data.info.size);


                  $('#sp').html(data.info.size);

                }                 
            });              
        }
        updateDiv();
        setInterval(updateDiv, 10000);
    });
 </script>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.