Nathan
Nathan

Reputation: 509

Show ajax retrieved HTML inside a div

i am looking to use ajax to retrieve table data in a web app i am building how ever i am running into a few issues

the ajax and the div work correctly however what i am chasing is inside the div to have the html code display i am using the below

    <script>
    function webapp_get_customers(){
       $.ajax({
       type: 'GET',
       url: '/limitless/cu.php',
       dataType: 'html'
      }).done(function( data ) {
      $('#webapp_get_customers').html(data);
      });
    }   
    </script>       


    <div id='webapp_get_customers'>the data on cu.php is displayed here</div>   

with the above code it when viewing the source code in a browser it doesn't show the html table on cu.php i am hoping to get the below when browsing the source in a browser

<div id='webapp_get_customers'>
 <table>
  <tr><td>some data inside the cu.php page</td></tr>
 </table>
</div>  

Upvotes: 1

Views: 449

Answers (1)

caballerog
caballerog

Reputation: 2739

You should call your function webapp_get_customers in your code.

For example:

<script>
    function webapp_get_customers(){
       $.ajax({
       type: 'GET',
       url: '/limitless/cu.php',
       dataType: 'html'
      }).done(function( data ) {
      $('#webapp_get_customers').html(data);
      });
    }   
    webapp_get_customers();
    </script>       


    <div id='webapp_get_customers'>the data on cu.php is displayed here</div>   

Upvotes: 1

Related Questions