Results 1 to 2 of 2

Thread: AJAX - Displaying a table

  1. #1
    Join Date
    Sep 2010
    Posts
    38

    AJAX - Displaying a table

    My page retrieves data from a MySQL database. The PHP script outputs a string of values that should produce a table on the page.


    So far I have tried the following approaches without success

    1. I get the PHP script to output the whole table as a response string to a request.

    Echo "<table><td><tr>value1...........etc.....</table>";
    Then I insert the response text into a <div> on the page using

    innerHTML = response text (JavaScript)

    This way I get the data out as a string of values.

    2. I have the opening and closing table tags on the page <table></table>.
    I then insert the rows again using innerHTML.


    If I run the PHP script in 1 on its own, I get the table that I want on thescreen. I just cannot insert it in the place that I want on the page.


    I know the methods I use are wrong. Any suggestions?

  2. #2
    Join Date
    Sep 2010
    Posts
    38
    I figured it out!

    My method described in #1 works. I had made the mistake of removing the HTML tags from the response text, hence the strange output - no table.

Similar Threads

  1. ajax help please
    By ActingRude in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 03 Nov 2010, 01:27 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
  •