Ajax div inside a table tag doesn't work!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • heyi
    New Member
    • Nov 2008
    • 3

    Ajax div inside a table tag doesn't work!

    Hi Guys


    I need some expert advice on Ajax.
    I have some difficulties updating a <div> tag inside a table with Ajax.


    My html looks like this:

    ------------------------

    ...
    [HTML]<table>
    <tr>
    <td>
    <img src="../photos/abc_thumb.jpg" onClick="Load_F ull_Size('abc') " />

    <div id="abc" ></div>

    </td></tr>
    </table>
    [/HTML]...

    ------------------------
    The content I want to add inside <div> tag is the following (extra) <img> tag:

    [HTML]<img src="../photos/abc_full_size.j pg" />
    [/HTML]

    This will be done by a php script which is already tested & functioning.
    ------------------------
    The Ajax for this task is like following:


    Code:
    var objXMLHttpReq1 = createXMLHttpReq();
    var urlPhotoPhp = "showphoto.php?photo=";
    
    
    function Load_Full_Size(strItemPhoto)
    {
    
    	objXMLHttpReq1.open("GET", urlPhotoPhp + escape(strItemPhoto) , true);
    	objXMLHttpReq1.onreadystatechange = Response_Handler_Photo();
                    objXMLHttpReq1.send(null);
    
    
    }
    
    
    function Response_Handler_Photo()
    {
    		
    	if (objXMLHttpReq1.readyState == 4)	
                    {
    			
    	             document.getElementById(strItemPhoto).innerHTML = objXMLHttpReq1.responseText;
    	}
    }
    
    
    function createXMLHttpReq()
    {
    	var objXMLHttpReq;
    	
    	if (window.XMLHttpRequest)
    	{
    		// Other Browsers
    		//
    		objXMLHttpReq = new XMLHttpRequest();
    
    }
    	else if (window.ActiveXObject)
    	{
    		// IE
    		//
    		objXMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    
    }
    
    	return objXMLHttpReq;
    
    }
    ------------------------

    Apparently, the whole thing works when <div> is outside the table, but I need the full size pic inside the table :/

    Any ideas? Thanks.
    Last edited by acoder; Nov 19 '08, 06:20 PM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    What I noticed is that the variable is named objXMLHttpReq, but you're using objXMLHttpReq1 or is that a typo?

    Comment

    • heyi
      New Member
      • Nov 2008
      • 3

      #3
      sorry that was a typo only here.. (this i had correct in my code). thx

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Is it necessary to make an Ajax request if all you want to do is to display an image? You can just create an image object, set its src to the full image source and append it to the div, or even set the innerHTML property.

        Comment

        Working...