Refreshing and Scrolling JSON

As I continue to try to figure this out, I have a page here that does what it is supposed to do but I would like to make two changes:

1) Is there a way to make the table visible onload?
2) Is there a way to periodically refresh the table without user action?  This page will be on view as races continue and I would like it to continue to refresh.
Bob SchneiderCo-OwnerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Slick812Commented:
greetings  Bob Schneider, , There is much in your page code as Javascript, that does not do what is needed, and the way you have the AJAX setup could be better. you have this button -
     <button id="btnGetData" type="button" style="margin-left: 5px;">View All Results</button>
inside of a FORM, you do not need the <form> at all, also you don NOT need the -
     type="button"  
as this is a button , not an input

In your javescript you have in this -
      $('button#btnGetData').click(function(){

where it gets an event_id  Value with this -
      var event_id=$(this).val();

BUT your button has NO VALUE to get, so you send an "undefined" to your function -
       doResults(event_id);

and this must be a mistake you have the -
       doResults( );
a second time? ? ?


you can use the JQuery  $( document ).ready()   method to call your  doResults( );   function to have the results shown on load.
See the Jquey manual for info about $( document ).ready()  at -
     http://learn.jquery.com/using-jquery-core/document-ready/

Also, if you use a Jquery version Before the version 1.11.0, then your AJAX will not work in the new version of Internet Explorer, you use this -
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

which is an older version of Jquery, and will not work for IE 11
0
Big MontyWeb Ninja at largeCommented:
to load the table automatically, simply call your ajax function:

$( document ).ready(function() {
    var event_id = 6;       //-- set your default ID value here
    doResults(event_id);
});

Open in new window


to do the refresh, you would add a setInterval() function call to your code:

$( document ).ready(function() {
    var event_id = 6;       //-- set your default ID value here
    doResults(event_id);

    setInterval(function(){
        doResults(event_id) // this will run after every 5 seconds
     }, 5000);

});

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob SchneiderCo-OwnerAuthor Commented:
Thanks all!

BTW, Is this correct?

"}, 5000);"
0
Big MontyWeb Ninja at largeCommented:
yes, i put it on its own line so I could add the comment on the previous lines. you can have the entire call on a single line if you like
0
Bob SchneiderCo-OwnerAuthor Commented:
Thanks!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.