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

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -