javascript - Updating element in webpage from php echo -


i'm building system auto update if needed, of app runs fine there 1 section can't working , it's when want update element, know return working because i've used console.log output , it's working fine.

here js (original attempt):

$(document).ready(function(){//starts applications (init)         $('.trade_window').load('signals.php?action=init', setinterval(function(){             console.log("test!!!");             $('.market_number_1').load('signals.php?action=check', function(){                 console.log("test2");                 // console.log(result);             });         }, 1000));       }); 

second attempt:

$(document).ready(function(){//starts applications (init)         $('.trade_window').load('signals.php?action=init', setinterval(function(){             $.ajax({                 url: 'signals.php?action=check&param=' + json.stringify({                     'market_number'     : $('.trade_window .market_name_1').text().trim(),                     'market_name'       : $('.trade_window .market_name_1').text().trim(),                     'trade_type'        : $('.trade_window .status').text().trim(),                     'trade_start_price' : '1.1234',                     'trade_open_time'   : '18:21:02'                                                         }),                   type: 'get',                 success: function(result){                     console.log("return was: " + result);                     $('.trade_window .market_number_1').load(result);                 }             })         }, 1000));       }); 

i have set php code testing:

<?php elseif (!empty($_get) && !empty($_get['action']) && $_get['action'] == "check") : ?> <?php echo "check working"; ?> <?php endif; ?> 

you might pick i'm not master of javascript of yet, in learning process amazing.

note php file outputs html , data, please let me know if need see this.

i think need call setinterval inside callback function of load...

$('.trade_window').load('signals.php?action=init',function(){         console.log("test!!!");         setinterval(function(){           $('.market_number_1').load('signals.php?action=check', function(){              console.log("test2");             // console.log(result);           });        }, 1000);   });   

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -