11Tami Posted May 7, 2007 Share Posted May 7, 2007 Hello I have a function that returns text only. How would I adjust this if I wanted it to get images too? function handleResponse() { if(http.readyState == 4 && http.status == 200){ // Text returned FROM PHP script var response = http.responseText; if(response) { // UPDATE ajaxTest content document.getElementById("countPosts").innerHTML = response; setTimeout('countPosts()',2000); } I would imagine I would also add this document.getElementById("countPosts").src = response; But then I'm not sure what I would do with this--how would I add an image src to this next? var response = http.responseText; Please let me know, thank you very much. Quote Link to comment Share on other sites More sharing options...
11Tami Posted May 7, 2007 Author Share Posted May 7, 2007 I think I'm taking the wrong approach on this. The http request is calling another page called test.php. And putting it all in an id called "countposts." I'm trying to pull an image from that page. So basically I'm just trying to call whats in the page, not any text at all. So I think I can get rid of the text commands in the javascript and do something like this instead. But I think there is something missing in the getelement by id, like a src. command or something. Anyone know how to take an image from a php page and stick it in an id? function handleResponse() { if(http.readyState == 4 && http.status == 200){ document.getElementById("countPosts") setTimeout('countPosts()',2000); } Quote Link to comment Share on other sites More sharing options...
mainewoods Posted May 7, 2007 Share Posted May 7, 2007 why don't you just have test.php return an entire image tag: test.php <img src="<?php echo $imageurl; ?>"> Quote Link to comment Share on other sites More sharing options...
11Tami Posted May 8, 2007 Author Share Posted May 8, 2007 Thats a unique approach. Downside is this is how it loads, with no image appearing because of it. http://www.website.com/%3Cimg%20src='/file02.jpg'%3E So I put this in the brackets and the double quotations instead. <img src="=<?php echo $imageurl; ?>"> Great thing is the images appeared! But now I have this on the viewing part of the page on both sides of the image. <img src=""> Anyone know how I can get rid of it? Once that is gone I'll be good to go. Thank you very much. Quote Link to comment Share on other sites More sharing options...
11Tami Posted May 8, 2007 Author Share Posted May 8, 2007 I got it, I just colored the text. Thanks I'll send you something. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.