Updating PHP populated table using ajax


I have a page that has an collapsible accordion layout.

In accordion section B, the following PHP code is invoked :
                  <?php showUserCourseModules();?>

Open in new window

showUserCourseModules() basically creates a table id='uniqueTable' on the fly, by querying a database.

In accordion section A, I have a form that allows user to add entries to the database using ajax.
The function looks somewhat like this :

function addnew() {
  var scriptURL="addModule.php?moduleCodeInput="+moduleCode;
                success: function(textStatus){
                    resultone = textStatus;
                        if (resultone == 1){
                            DO SOMETHING
                        else if (resultone == 2){
                           document.getElementById().refresh("uniqueTable");  <---- THIS DOESNT WORK. 
                        else if (resultone == 3){
                           location.reload(); <---------------------THIS WORKS, but refreshes the whole page
and so on

Open in new window

How should i actually attempt to do this? I think the reason why it isnt working is because basically i have an ajax jquery code that is trying to request a table created using php to refresh. But there must be a way to do this?

Thanks for help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Here is a very rudimentary example (link here)

Demonstrates the concept files attached

t826.php - html file - calls showCourseModules from included file.
coursemodule.php - common code to draw the table
addmodule.php - code to handle post from html - also includes coursemodule.php.

Key is that main page and addmodule include the same coursemodule file - common code to render the table.
After a module is added coursemodule is called and the html returned to the browser - this is then used to update the <article> section in the JQuery success function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NeverEndingFlashStoriesAuthor Commented:
Thanks so much Julian!
Julian HansenCommented:
You are most welcome - good luck with it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.