Do you really need to "build" it from javascript or can you simply return the built HTML from PHP and insert it into the DOM?
- Send AJAX request to php script
- PHP script processes request and builds table
- PHP script sends response back to JS in form of encoded HTML
- JS takes response and inserts it into the DOM