SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    some help with jquery

    Hi

    I have this code
    Code:
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    
    function get() {
        $.post('js_data.php',
    function (output) {
    $('#test').html(output).show();
    });
    
    }
    
    </script>
    </head>
    
    <body>
    <input type = "button" name="button" id="button" value="Submit" onClick="get();">
    
    <div id = "test"></div>
    It displays the info in js_data.php whenever I click on the button.
    How do I get it to display the data when I open the page?

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You can do this 2 ways, if you want to execute the code between your <head> tags you can use...

    HTML Code:
    <script type="text/javascript">
        $(function() {
            get();
        });
    </script>
    else if you want to execute the code before your </body> tag you can simply use just use...

    HTML Code:
    <script type="text/javascript">
         get();
    </script>

  3. #3
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, is it possible to refresh the 'get' every few minutes so sql output is automatically updated?

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Have a read of the setInterval function https://developer.mozilla.org/en/window.setInterval


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •