habib009pk Posted September 10, 2009 Share Posted September 10, 2009 i am working on a ajax based page and i want to display ajax based images. on two different places, but as we know that we only get the response of ajax on the only one div through id. but i would like to ask that is it any possibility that we get the response of same function on two different divs through two different id. and what is the code for it. Waiting for you reply Regards Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted September 10, 2009 Share Posted September 10, 2009 Wat you are requesting is probably possible, you're question is vague though. Why don't you make a start yourself so people can help you with that? The community members are not here to write code for you Quote Link to comment Share on other sites More sharing options...
habib009pk Posted September 11, 2009 Author Share Posted September 11, 2009 Basically i want to display ajax based images, i have total 3 to 4 images which i want to display on a web page. These images are got through same query from a live web server, now i want to display 3 of these images on the center of webpage in a separate and one of these images at the top of the page with another div. Is it any possibilty that i got the responses of ajax on two different divs with the same function and same query. That is from this only one response i display the three images in the center of webpage and only one image display on the top of the web page omplete code is: Div for top image: <div id="second2"></div> Div for center images: <div id="second" style="height:335px; float:left; margin-top:3px;" align="center"> </div> ajax function: function show_images(lotid) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } // alert(str); var url="japan_auction_show_images_ajax.php" url=url+"?lotid="+lotid; xmlHttp.onreadystatechange=stateChanged_show_images xmlHttp.open("GET",url,true) xmlHttp.send(null) } //alert(st2) function stateChanged_show_images() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var a = "second"; document.getElementById(a).innerHTML=xmlHttp.responseText } } and PHP code for this ajax function <?php require_once('../../../../Connections/kansai.php'); ?> <?php if(!isset($_SESSION)) { session_start();} ?> <?php $lotid=$_GET['lotid']; $search=$_GET['search']; //Query for the find the images from Russian Server $is_gzip = 0; // parameter uses compression $gzip = '&gzip='.$is_gzip; $base = '?base=auct'; $action = '&action=lot_details'; $lot_id = '&lot_id='.$lotid; $lang='&lang=en'; $url = 'http://xml.aleado.ru/sql.php'.$base.$action.$gzip.$lot_id.$lang; $xml = @file_get_contents($url); if ($is_gzip) $xml = @gzuncompress($xml); if ($xml) $xml2 = simplexml_load_string($xml); $loopend = count($xml2); error_log(print_r($xml2,true),3,'dump.xml'); for($a=0;$a<$loopend;$a++) { $picsurls=addslashes($xml2->item[$a]->pics_urls); $parsed_data=addslashes($xml2->item[$a]->parsed_data); } //$xml = $parsed_data; $doc = new DOMDocument(); $doc->loadXML($xml); $data = $doc->getElementsByTagName('parsed_data')->item(0)->nodeValue; preg_match_all('~<([^>]+)>([^>]+)</[^>]+>~', $data, $matches, PREG_SET_ORDER); $hash = array(); foreach ($matches as $match) { $hash[$match[1]] = $match[2]; } $pieces = explode("#", $picsurls); ?> <div id="second" style="height:335px; float:left; margin-top:3px;"> <?php if($pieces[3]=='') { ?> <div style="clear:left;"> <!--second...pictures showing div--> <div id="pics" style="width:50%; height:335px; float:left;" align="center"> <span style="float:left"> <?php if($pieces[1]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available" width="160" height="100" border="0" /> <?php } else { ?> <img id="imgBamburgh3" alt="" src="<?php echo $pieces[1]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="160" height="100" border="0" style="padding:2px;" /> <?php } ?> </span> </div> <div style="width:50%; height:335px; float:left;"> <?php if($pieces[2]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="160" height="100" border="0" /> <?php } else { ?> <img id="imgBamburgh2" alt="" src="<?php echo $pieces[2]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="160" height="100" border="0" style="padding:2px;" /> <?php } ?> </div> </div> <?php } else { ?> <div style="clear:left;"> <!--second...pictures showing div--> <div id="pics" style="height:335px; float:left;" align="center"> <span style="float:left"> <?php if($pieces[1]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available" width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh3" alt="" src="<?php echo $pieces[1]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </span> </div> <div style="width:33%; height:335px; float:left;"> <?php if($pieces[2]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh2" alt="" src="<?php echo $pieces[2]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </div> <div style="width:33%; height:335px; float:left;"> <?php if($pieces[3]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh5" alt="" src="<?php echo $pieces[3]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </div> </div> <?php } ?> </div> Quote Link to comment Share on other sites More sharing options...
habib009pk Posted September 11, 2009 Author Share Posted September 11, 2009 Basically i want to display ajax based images, i have total 3 to 4 images which i want to display on a web page. These images are got through same query from a live web server, now i want to display 3 of these images on the center of webpage in a separate and one of these images at the top of the page with another div. Is it any possibilty that i got the responses of ajax on two different divs with the same function and same query. That is from this only one response i display the three images in the center of webpage and only one image display on the top of the web page omplete code is: ajax function calling <script language="javascript" type="text/javascript"> window.onLoad = show_images(<?php echo $lotid; ?>); </script> Div for top image: <div id="second2"></div> Div for center images: <div id="second" style="height:335px; float:left; margin-top:3px;" align="center"> </div> ajax function: function show_images(lotid) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } // alert(str); var url="japan_auction_show_images_ajax.php" url=url+"?lotid="+lotid; xmlHttp.onreadystatechange=stateChanged_show_images xmlHttp.open("GET",url,true) xmlHttp.send(null) } //alert(st2) function stateChanged_show_images() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var a = "second"; document.getElementById(a).innerHTML=xmlHttp.responseText } } and PHP code for this ajax function <?php require_once('../../../../Connections/kansai.php'); ?> <?php if(!isset($_SESSION)) { session_start();} ?> <?php $lotid=$_GET['lotid']; $search=$_GET['search']; //Query for the find the images from Russian Server $is_gzip = 0; // parameter uses compression $gzip = '&gzip='.$is_gzip; $base = '?base=auct'; $action = '&action=lot_details'; $lot_id = '&lot_id='.$lotid; $lang='&lang=en'; $url = 'http://xml.aleado.ru/sql.php'.$base.$action.$gzip.$lot_id.$lang; $xml = @file_get_contents($url); if ($is_gzip) $xml = @gzuncompress($xml); if ($xml) $xml2 = simplexml_load_string($xml); $loopend = count($xml2); error_log(print_r($xml2,true),3,'dump.xml'); for($a=0;$a<$loopend;$a++) { $picsurls=addslashes($xml2->item[$a]->pics_urls); $parsed_data=addslashes($xml2->item[$a]->parsed_data); } //$xml = $parsed_data; $doc = new DOMDocument(); $doc->loadXML($xml); $data = $doc->getElementsByTagName('parsed_data')->item(0)->nodeValue; preg_match_all('~<([^>]+)>([^>]+)</[^>]+>~', $data, $matches, PREG_SET_ORDER); $hash = array(); foreach ($matches as $match) { $hash[$match[1]] = $match[2]; } $pieces = explode("#", $picsurls); ?> <div id="second" style="height:335px; float:left; margin-top:3px;"> <?php if($pieces[3]=='') { ?> <div style="clear:left;"> <!--second...pictures showing div--> <div id="pics" style="width:50%; height:335px; float:left;" align="center"> <span style="float:left"> <?php if($pieces[1]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available" width="160" height="100" border="0" /> <?php } else { ?> <img id="imgBamburgh3" alt="" src="<?php echo $pieces[1]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="160" height="100" border="0" style="padding:2px;" /> <?php } ?> </span> </div> <div style="width:50%; height:335px; float:left;"> <?php if($pieces[2]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="160" height="100" border="0" /> <?php } else { ?> <img id="imgBamburgh2" alt="" src="<?php echo $pieces[2]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="160" height="100" border="0" style="padding:2px;" /> <?php } ?> </div> </div> <?php } else { ?> <div style="clear:left;"> <!--second...pictures showing div--> <div id="pics" style="height:335px; float:left;" align="center"> <span style="float:left"> <?php if($pieces[1]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available" width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh3" alt="" src="<?php echo $pieces[1]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </span> </div> <div style="width:33%; height:335px; float:left;"> <?php if($pieces[2]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh2" alt="" src="<?php echo $pieces[2]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </div> <div style="width:33%; height:335px; float:left;"> <?php if($pieces[3]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh5" alt="" src="<?php echo $pieces[3]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </div> </div> <?php } ?> </div> Quote Link to comment Share on other sites More sharing options...
habib009pk Posted September 11, 2009 Author Share Posted September 11, 2009 Basically i want to display ajax based images, i have total 3 to 4 images which i want to display on a web page. These images are got through same query from a live web server, now i want to display 2 to 3 of these images on the center of webpage in a separate div and one of these images at the top of the page with another div. Is it any possibilty that i got the responses of ajax on two different divs with the same function and same query. That is from this only one response i display the three images in the center of webpage and only one image display on the top of the web page omplete code is: Div for top image: <div id="second2"></div> Div for center images: <div id="second" style="height:335px; float:left; margin-top:3px;" align="center"> </div> ajax function: function show_images(lotid) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } // alert(str); var url="japan_auction_show_images_ajax.php" url=url+"?lotid="+lotid; xmlHttp.onreadystatechange=stateChanged_show_images xmlHttp.open("GET",url,true) xmlHttp.send(null) } //alert(st2) function stateChanged_show_images() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var a = "second"; document.getElementById(a).innerHTML=xmlHttp.responseText } } and PHP code for this ajax function <?php require_once('../../../../Connections/kansai.php'); ?> <?php if(!isset($_SESSION)) { session_start();} ?> <?php $lotid=$_GET['lotid']; $search=$_GET['search']; //Query for the find the images from Russian Server $is_gzip = 0; // parameter uses compression $gzip = '&gzip='.$is_gzip; $base = '?base=auct'; $action = '&action=lot_details'; $lot_id = '&lot_id='.$lotid; $lang='&lang=en'; $url = 'http://xml.aleado.ru/sql.php'.$base.$action.$gzip.$lot_id.$lang; $xml = @file_get_contents($url); if ($is_gzip) $xml = @gzuncompress($xml); if ($xml) $xml2 = simplexml_load_string($xml); $loopend = count($xml2); error_log(print_r($xml2,true),3,'dump.xml'); for($a=0;$a<$loopend;$a++) { $picsurls=addslashes($xml2->item[$a]->pics_urls); $parsed_data=addslashes($xml2->item[$a]->parsed_data); } //$xml = $parsed_data; $doc = new DOMDocument(); $doc->loadXML($xml); $data = $doc->getElementsByTagName('parsed_data')->item(0)->nodeValue; preg_match_all('~<([^>]+)>([^>]+)</[^>]+>~', $data, $matches, PREG_SET_ORDER); $hash = array(); foreach ($matches as $match) { $hash[$match[1]] = $match[2]; } $pieces = explode("#", $picsurls); ?> <div id="second" style="height:335px; float:left; margin-top:3px;"> <?php if($pieces[3]=='') { ?> <div style="clear:left;"> <!--second...pictures showing div--> <div id="pics" style="width:50%; height:335px; float:left;" align="center"> <span style="float:left"> <?php if($pieces[1]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available" width="160" height="100" border="0" /> <?php } else { ?> <img id="imgBamburgh3" alt="" src="<?php echo $pieces[1]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="160" height="100" border="0" style="padding:2px;" /> <?php } ?> </span> </div> <div style="width:50%; height:335px; float:left;"> <?php if($pieces[2]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="160" height="100" border="0" /> <?php } else { ?> <img id="imgBamburgh2" alt="" src="<?php echo $pieces[2]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="160" height="100" border="0" style="padding:2px;" /> <?php } ?> </div> </div> <?php } else { ?> <div style="clear:left;"> <!--second...pictures showing div--> <div id="pics" style="height:335px; float:left;" align="center"> <span style="float:left"> <?php if($pieces[1]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available" width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh3" alt="" src="<?php echo $pieces[1]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </span> </div> <div style="width:33%; height:335px; float:left;"> <?php if($pieces[2]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh2" alt="" src="<?php echo $pieces[2]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </div> <div style="width:33%; height:335px; float:left;"> <?php if($pieces[3]=='') { ?> <img alt="" src="../../../../media/images/not_available.jpg" title="Auction Sheet Not Available"width="105" height="70" border="0" /> <?php } else { ?> <img id="imgBamburgh5" alt="" src="<?php echo $pieces[3]; ?>" class="PopBoxImageSmall" title="Click to magnify/shrink" onclick="Pop(this,50,'PopBoxImageLarge');" width="105" height="70" border="0" style="padding:2px;" /> <?php } ?> </div> </div> <?php } ?> </div> 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.