0

I'm making an ajax request to my PHP script which will echo out a certain # of tables ( different each time), that I want to include on my original page when a user clicks the submit_form button. My question is how can i get Jquery to display this table into the table_layout div?

HTML :

<div id="table_layout"> </div>

JQUERY

$( ".submit_form" ).click(function( e ) {


          $.ajax({
          type : 'GET',
          url:  'draw_tables.php',
          dataType : 'html',
          data:  dataString ,
          error : function(XMLHttpRequest, textStatus, errorThrown) {
          alert('error'); },
          success : function(data) { //appendto.('#table_layout')   } 
          });    
          return false; 
          })

PHP (draw_tables.php)

echo '<table>';
echo '<input type="text" name="ID">';
echo '<input type="text" name="CLASS">';
echo '</table>';
3
  • Between table_layout and what ? Commented Dec 6, 2012 at 20:39
  • @RicardoLohmann sorry fixed left out the html part Commented Dec 6, 2012 at 20:40
  • So, it's not between. It's in. Commented Dec 6, 2012 at 20:41

3 Answers 3

2

For example you could make an ajax request and fill the div with it

 $.get("draw_tables.php", function(data) {
 $("#table_layout").html(data);
 });

This will fill your table_layout id with the data from the ajax request.

Sign up to request clarification or add additional context in comments.

Comments

1
$('#table_layout').append(data);

1 Comment

the problem is im not returning any data back it's just echoing out the table from PHP
0

Inside the success callback you should add:

$('#table_layout').append(data);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.