I am using an AJAX request to return 'raw' HTML content, which I was then planning to manipulate before rendering it on the page. The AJAX request returns the HTML data:
function AjaxTest(url){
$.ajax({
url: "index.aspx?" + url,
success: function(result){gatherData(result)},
dataType: 'html'
});
}
I then call another function called gatherData(result)
with the result of the AJAX request as the function parameter.
function gatherData(data){
var $data = $(data);
tables = $data.find('body table');
At this point my tables
var is empty, but I expected it to reference to the tables found within the AJAX responses' body. Is there any way to manipulate the HTML returned via. an AJAX request before rendering it? Below is the HTML response from the AJAX request. All I need to do is access the tables within the body.
<!DOCTYPE HTML><html>
<HEAD>
<title></title>
</HEAD>
<BODY>
<TABLE border=1 cellspacing=0 cellpadding=0 alignment="">
<TBODY>
<TR><TD>x-value</TD><TD>Financial Plan</TD></TR><TD>09/11/2015</TD>
<TD>0</TD>
</TR><TD>10/11/2015</TD>
<TD>0</TD>
</TR><TD>11/11/2015</TD>
<TD>0</TD>
</TR><TD>12/11/2015</TD>
<TD>0</TD>
</TR><TD>13/11/2015</TD>
<TD>0</TD>
</TR><TD>14/11/2015</TD>
<TD>0</TD>
</TR><TD>15/11/2015</TD>
<TD>0</TD>
</TR></TBODY></TABLE><TABLE border=1 cellspacing=0 cellpadding=0 alignment="">
<TBODY>
<TR><TD>x-value</TD><TD>Business Forecast</TD></TR><TD>09/11/2015</TD>
<TD>0</TD>
</TR><TD>10/11/2015</TD>
<TD>0</TD>
</TR><TD>11/11/2015</TD>
<TD>0</TD>
</TR><TD>12/11/2015</TD>
<TD>0</TD>
</TR><TD>13/11/2015</TD>
<TD>0</TD>
</TR><TD>14/11/2015</TD>
<TD>0</TD>
</TR><TD>15/11/2015</TD>
<TD>0</TD>
</TR></TBODY></TABLE><TABLE border=1 cellspacing=0 cellpadding=0 alignment="">
<TBODY>
<TR><TD>x-value</TD><TD>Operational Planned</TD></TR><TD>09/11/2015</TD>
<TD>0</TD>
</TR><TD>10/11/2015</TD>
<TD>0</TD>
</TR><TD>11/11/2015</TD>
<TD>66358</TD>
</TR><TD>12/11/2015</TD>
<TD>65990</TD>
</TR><TD>13/11/2015</TD>
<TD>55993</TD>
</TR><TD>14/11/2015</TD>
<TD>0</TD>
</TR><TD>15/11/2015</TD>
<TD>0</TD>
</TR></TBODY></TABLE><TABLE border=1 cellspacing=0 cellpadding=0 alignment="">
<TBODY>
<TR><TD>x-value</TD><TD>Actual</TD></TR><TD>09/11/2015</TD>
<TD>0</TD>
</TR><TD>10/11/2015</TD>
<TD>0</TD>
</TR><TD>11/11/2015</TD>
<TD>62202</TD>
</TR><TD>12/11/2015</TD>
<TD>59261</TD>
</TR><TD>13/11/2015</TD>
<TD>49119</TD>
</TR><TD>14/11/2015</TD>
<TD>0</TD>
</TR><TD>15/11/2015</TD>
<TD>0</TD>
</TR></TBODY></TABLE>
</BODY>
</HTML>