Reputation: 1024
Hi All I have a an AJAX query as seen below:
function buttonCallback(obj){
var id = $(obj).attr('id');
$.ajax({
type: "POST",
url: "/project/main/passid",
data: { 'id': id },
success: function(msg){
$("#reloadtable").html("result reloaded successfully"); //? reload?
}
});
}
the query successfully runs - I was hoping to reload a table I have created in html after the query runs - I took some code from another post but it doesn't seem to run - my table body tag is:
<tbody class = "tablereload">
I am entirely new to JS so I apologise if this question is stupid or incorrect - but I am hoping to reload the body of the table after the query has run - is this possible? or refreshing the whole page - without redirect?
Upvotes: 1
Views: 80
Reputation: 449
Your have a ID selector and in the html you have a class for the tbody.
You can put the Id for the tbody
<tbody id = "tablereload">
or change the script
$(".reloadtable").html("result reloaded successfully");
Upvotes: 0
Reputation: 2815
The page /project/main/passid
should return html like (echo it if it is php page)
<tr>
<td>.....</td>
</tr>
And changes to you Ajax call:
function buttonCallback(obj){
var id = $(obj).attr('id');
$.ajax({
type: "POST",
url: "/project/main/passid",
data: { 'id': id },
success: function(msg){
$(".tablereload").html(msg); //? reload?
}
});
}
Upvotes: 2