html5 - Extract a table using ajaxjquery response -
i take whole html code page extracting table. here code.
$(document).ready(function () { alert("hello"); $.ajax( { url: '/member/downloadurldata', type: "post", datatype: "html", async: true, cache: false, beforesend: function (request) { }, success: function (data) { // $('#rdata').load('data #container'); alert(data); var thehtml = $.parsehtml(data).filter('#container>table:first').html(); $("#rdata").append(thehtml); }, error: function (xmlhttprequest, textstatus, errorthrown) { }, complete: function (xmlhttprequest, textstatus) { } }); <div id="rdata"> </div>
but cant extract table.the problem shown in error log '#container>table:first' not function. how can solve this.
since data
html markup, try
$(data).find('#container>table:first').html();
ex:
$(document).ready(function () { alert("hello"); $.ajax({ url: '/member/downloadurldata', type: "post", datatype: "html", async: true, cache: false, beforesend: function (request) { }, success: function (data) { alert(data); var html = $.parsehtml(data); var table = $(html).find('#container>table:first'); $("#rdata").append(table); }, error: function (xmlhttprequest, textstatus, errorthrown) { }, complete: function (xmlhttprequest, textstatus) { } }); });
demo: fiddle
Comments
Post a Comment