I am making an ajax call and I am getting the content from the responseText .
I confirm that inside the alert inside the responseText contains the whole page as a string .
It's good. Now I need to extract the specific content from the string, translating it to the DOM and using getElementsByTagName , getElementsByName , etc.
My problem is that none of them work.
I have read many references to using responseXML instead of responseText , but this returns me null .
So, adhering to responseText , how can I get the specific elements that I want?
For example, if my answer contains the following:
<html> <head>....</head> <body>.... ..... <table> <tr> <td>sometext</td> <td>someothertext</td> </tr> <tr> <td>sometext</td> <td>someothertext</td> </tr> <tr> <td>sometext</td> <td>someothertext</td> </tr> </table> <div> somediv </div> </body> </html>
How can I access the second row of the table and its value? Or div, etc. so now in my actual html, I have sth like this
<html> <head>.....</head> <body> <table><tr><td id="test">Test</td></tr></table> </body> </html>
I want the extracted item / value to be parsed inside the table of my actual html ..
document.getElementById ('test'). innerHTML = the_extracted_elements_from_responseText
source share