Using Jquery .load To Add Rows To An Html Table
The code below adds the html returned by returndatafromdb2() function in the server to the table that has id resultstable2. The html returned by the function returndatafromdb2() is
Solution 1:
There isn't a way to do it with the load()
function. You will want to use the normal ajax calls and write your own callback function. Something like this:
var getdata2 = function() {
var loadurl2 = "{{=URL('default', 'returndatafromdb2')}}";
$.get(loadurl2,function(data){
$('#resultstable2').append(data);
},'html');
};
$('#b2').click(getdata2);
Solution 2:
Just use append
instead of load()
var getdata2 = function() {
var loadurl2 = "{{=URL('default', 'returndatafromdb2')}}";
$.get(loadurl2,function(data){
//Here goes the append :-)
$('#resultstable2').append(data);
},'html');
};
$('#b2').click(getdata2);
Solution 3:
jQuery.get( loadurl2 ,'', function(d){
$('#resultstable2').append(d);
} )
Post a Comment for "Using Jquery .load To Add Rows To An Html Table"