Javascript when to show results

Posted by Pete on Stack Overflow See other posts from Stack Overflow or by Pete
Published on 2010-03-24T23:50:03Z Indexed on 2010/03/24 23:53 UTC
Read the original article Hit count: 288

Filed under:
|

This is my Javascript below I want to show records on load and also show new records when added to the database

showrecords(); displays the records in the database where abouts can I put this in my code where it will work correctly.

`$(document).ready(function() { //showrecords()

function showrecords()
{
    $.ajax({
        type: "POST",
        url: "demo_show.php",
        cache: false,
        success: function(html){

            $("#display").after(html);

            document.getElementById('content').value='';
            $("#flash").hide();

         }

});

}

$(".comment_button").click(function() {

    var element = $(this);
    var test = $("#content").val();
    var dataString = 'content='+ test;

    if(test=='')
        {
        alert("Please Enter Some Text");

        }
    else
        {
            $("#flash").show();
            $("#flash").fadeIn(400).html('<img src="http://tiggin.com/ajax-loader.gif" align="absmiddle">&nbsp;<span class="loading">Loading Comment...</span>');


    $.ajax({
    type: "POST",

url: "demo_insert.php", data: dataString, cache: false, success: function(html){

// $("#display").after(html); document.getElementById('content').value=''; $("#flash").hide();

//Function for showing records //showrecords();

}

}); }

return false;
});

}); `

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about JavaScript