javascript - Script load on xhr response -
i have problem responsetext. want load script includes/dodaj-slike.php (which echo)
xhr.onreadystatechange = function(e) { if(this.readystate === 4) { alert(xhr.responsetext); } }; xhr.open('post', 'includes/dodaj-slike.php', true); xhr.send(formdata);
alert responsetext (example) :
<script type='text/javascript'> $('ul li:nth(0)').append('<img src='uploads/cropped_2013-08-12 00.50.37.jpg'/>'); </script> <script type='text/javascript'> $('ul li:nth(1)').append('<img src='uploads/cropped_2013-08-18 12.56.24.jpg'/>'); </script>
i , want somehow load script after response.
my question how load script on way?
you can with
document.head.appendchild(responsetext);
correct way suggested
$("head").append(xhr.responsetext);
Comments
Post a Comment