FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
image Loading with XMLHTTP
Message  

Reply with quote
Post image Loading with XMLHTTP 
Hi everybody
I want to use XMLHTTP to show an image.it loads finely
but can't show.
i use IE.
Quote:

<script type="text/javascript">
var xmlhttp;
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for all new browsers
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5 and IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET","image.jpg",true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = OK
//showing the image
document.write(xmlhttp.responseXML);
}
else
{
alert("Problem retrieving XML data");
}
}
}
</script>

thank you inadvance

View user's profile Send private message

Reply with quote
Post  
Never tried to use the XMLHttpRequest to open an image. This function is used for text data. Not sure if image preloading would work in this case. What I would suggest you is this:

Code:

function imageLoader(s, fun)
{
   var i = new Image();
   i.onload=function (){setTimeout(fun, 0)};
   i.src=s;
}


here s is the source of your image (image.jpg in your case) and the fun is the name of the function that would be called as soon as the image loads.

Regards,
Pratamishus


_________________
www.eb-downloads.com
FREE E-BOOKS DOWNLOADS.
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com