Some help with jquery

Hi

I have this 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?

You can do this 2 ways, if you want to execute the code between your <head> tags you can use…

<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…

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

Hi, is it possible to refresh the ‘get’ every few minutes so sql output is automatically updated?

Have a read of the setInterval function https://developer.mozilla.org/en/window.setInterval