Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2004
    Location
    Nashville
    Posts
    202
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting Data From External File to Append

    Greetings,

    I've got a table which upon initially opening shows 20 rows. I would like the user to be able to click a button to Add 20 Rows.

    I've got 20 rows of table formatting in a file called ('includes/table.php'). I'd like for jquery to bring the data from this file and append it to my table.

    Button: #addMore
    Table: #participants

    Code:
    	<script>
    	$(document).ready(function() {
    		$("#addMore").click(function() {
    			$.get("includes/table.php", function(data) {
    				$("#participants tr:last").append(data);
    			});
    		});
    	});
    	</script>

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    appendTo

    example


    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
     $('<p>to play</p>').appendTo("#test");
    });
    </script>
    </head>
    
    <body>
    <div id="test">I like</div>
    </body>
    </html>
    spits out

    I like

    to play
    Last edited by seco; 05-06-2010 at 09:47 PM.


  •  

    Posting Permissions

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