Link to home
Start Free TrialLog in
Avatar of NeverEndingFlashStories
NeverEndingFlashStories

asked on

Updating PHP populated table using ajax

Hi,

I have a page that has an collapsible accordion layout.

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

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;
            $.ajax({
                url:scriptURL,
                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.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NeverEndingFlashStories
NeverEndingFlashStories

ASKER

Thanks so much Julian!
You are most welcome - good luck with it.