jquery add data to asp.net table using after function -


i'm going implement jquery infinite scroll in asp.net web app, use following jquery funcyion (taken http://code.msdn.microsoft.com/csaspnetinfiniteloading-16f5bdb8):

$(document).ready(function () {         function lastpostfunc() {            $('#divpostsloader').html('<img src="images/bigloader.gif">');             //send query server side present new content            $.ajax({                type: "post",                url: "default.aspx/foo",                data: "{}",                contenttype: "application/json; charset=utf-8",                datatype: "json",                success: function (data) {                     if (data != "") {                        $('.divloaddata:last').after(data.d);                    }                    $('#divpostsloader').empty();                }             })        }; 

divloaddata div receive data (in html format), want append data asp.net table, how can append data? should use after function? how should generate html appending server-side table control, data created using following code (in webmethod function):

  foreach (datarowview mydatarow in dv)             {                 getpoststext.appendformat("<p>author: {0}</br>", mydatarow["author"]);                 getpoststext.appendformat("genre: {0}</br>", mydatarow["genre"]);                 getpoststext.appendformat("price: {0}</br>", mydatarow["price"]);                 getpoststext.appendformat("publish date: {0}</br>", mydatarow["publish_date"]);                 getpoststext.appendformat("description: {0}</br></p>", mydatarow["description"]);             }             getpoststext.appendformat("<div style='height:15px;'></div>"); 

and getpoststext sent jquery

you can use .after() function in jquery append content after element.

so instead of

$("servers").append( ... ); 

you use

$("#" + id + ).closest( "tr" ).after( ... ); 

or use

$( ... ).insertafter( $("#" + id ).closest( "tr" ) ); 

which equivalent.

see http://api.jquery.com/after/ full details.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -