javascript - why DOM is null when evaluated in a callback function of an ajax call using jQuery.get()? -
i run function contents of html inside div #contents success. when use deferred.always callback function dom elements null ( included window! ). explain why , solution? thanks.
function loadhomec(){ $.get("../ajax/homec.html", function(data) { $(contents).html(data); }).always(function() { console.log(window.document.getelementbyid('myid').value); }); }
the data returned homec.html following :
<p> welcome </p> <ul> <li> <a href="#" onclick="loadnewtype()">create new object type</a></li> <li> <a href="#" onclick="loadtreefortypes()">create new object</a></li> <li> <a href="#">create new rulesset</a></li> </ul>
this fiddle shows works fine unless have exception in success handler. candidate, since still haven't provided how content
defined. given have jquery in project it's doubtful read dom object vanilla js , expect code should $('#contents').html(data);
Comments
Post a Comment