Reputation: 501
What is the best approach to have a form and a table in the same page, where the form has a submit button (ajaxsubmit) that saves the data in database and table should display the data without the need to refresh the page?
I have tried to call $.load to get the table, but some problems occurred due to the problem that $.load function finishes after document.ready
So shall i use iframe? or create an xml file and read the data into table?
Upvotes: 0
Views: 108
Reputation: 337560
To execute code after the $.load()
method has completed you need to place it in the callback
of the call to load()
.
For example:
$("#myElement").load(
'/location/of-target.html',
function(data) {
// put code here to execute after the load has completed.
// for example to append a specific div.
$(data).find("#myDiv").appendTo("#containerDiv");
}
);
Upvotes: 0
Reputation: 30088
take a look at this explanation of jQuery's ajaxForm and ajaxSubmit: http://www.justwebdevelopment.com/blog/ajaxform-and-ajaxsubmit-options/
Upvotes: 0