I have a PHP that returns an HTML snippet as string in the following format:
echo '<tr><td>blah</td><td>more blah</td></tr><tr><td>blah</td><td>more blah</td></tr><tr><td>blah</td><td>more blah</td></tr><span id="morerows">1</span>';
Now at the client, I am using JQuery (2.1.4) to extract the text of #morerows (in this example, 1) into a local var ifmore and then remove that <span> from the original HTML before further processing. Following is what I am trying for testing purposes:
var hr = createXMLHTTPRequestObject();
...
var return_data = hr.responseText;
var rdasHTML = $(return_data);
var ifmore = $('span#morerows', rdasHTML);
alert(ifmore.text());
But it only alerts blank. The HTTP request is processing fine because alert(return_data); shows the value expected. Only the extraction of the <span> element is somehow not working. Is there something I am missing out?