<div class="grid--cell fl1 lh-lg">
<div class="grid--cell fl1 lh-lg">
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, <a href="/help/reopen-questions">visit the help center</a>.
</div>
</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2012-11-23 06:07:06Z" class="relativetime">7 years ago</span>.</div>
</div>
</aside>
I send to a php page a request and the output is like that
<?php
echo "<div id=\"someid\">
innerHTML
</div>"
?>
I try to catch the element but it doesnt work
var a=document.getElementById('someid');
alert(a.innerHTML);//alert nothing
How do I fix it with pure javascript?
</div>
If you are getting the content of a PHP page with AJAX (not include
ing it), you have to append it to the DOM somewhere.
Are you appending it to the DOM in your code?
If you are using include
, require
, etc. then that is not AJAX.
You would have to wait until the page is loaded, so the code would go something like this:
window.onload = function() {
var elem = document.getElementById('foo');
alert(elem.innerHTML);
}
You need to put your code into a proper ajax structure. It should look like these examples.