Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005
    Posts
    203

    Smile Unanswered: Problem updating iframe content from server side

    Hi all i am using iframe to display some dynamic data and i make frequent request to server to see if new data is avaliable .But the problem is that aftr i manually update the iframecontent.php i do not see the changes on my main page !!If i hit f5 i see the change. could any one tell me why my code does not update it automatically without refreshing the whole page. i frequently call getnewdata()
    to fetch new data but it never updates the iframe display. I did lot of search to find out what is wrong but could not fix the problem so i be happy if some one help me fix it.Thanks

    data output on screen : But it never change even when i update iframecontent.php manually and make frequen call to it!!
    http://img3.freeimagehosting.net/uploads/c0411a81e9.jpg


    iframe inside javascript:

    Code:
    <div id="text" style="z-index:90;" class="chatWindowTextDisplay"
    title="Chat Transcript - "
    alt="Chat Transcript -"
    ><iframe name="textFrame" id="textFrame" src="http://localhost/ajaxWithoutHTPrequest/iframe/iframeContent.php?cmd=file&file=chatTemplate&template=chatText&amp;site=676789&amp;sessionkey=H9030219168890559071K46359640" frameborder="0" border="0" width="350" height="220" class="chatWindowTextFrame"
    title="Chat Transcript - "
    alt="Chat Transcript - "
    >This functionality requires frames. </a>.</iframe>
    </div>
    
    
    <script type="text/javascript">
    
    document.getElementById("text").tabindex = 3;
    document.getElementById("textFrame").tabindex = 3;
    
    </script>
    <script type="text/javascript">
    
    document.writeln('<div id="hiddentext" style="z-index:0;position:absolute;visibility:hidden;left:0;top:13px">'+
        '<iframe name="lpCommFrame" id="lpCommFrame" src="http://localhost/iframecontent.php" frameborder="0" border="0" width="350" height="220" title="Background">'+
        'This functionality requires frames. </iframe>'+
    '</div>');
    
    function getnewdata()
    {
    var u = "http://localhhost/iframecontent.php?cmd=file&file=chatText&site=676789&sessionkey=H7221484707459237529K46228278&d=" + jsGetDate();
    		document["lpCommFrame"].location = u;
    jsCheckCommFrame();
    
    }
    
    function jsGetDate()
    {
    	var d = new Date();
    	return d.getTime();
    }
    
    function jsCheckCommFrame() {
    
    //alert("jscheckcommframe");
    
    	var win = window.frames['lpCommFrame'];
    	try{
            if ((typeof(win) == "undefined") || (win.document.body == null) || (typeof(win.document.body) == "undefined"))
                return;
    	}catch(e){
    	    reportError(e,'jsCheckCommFrame_win');
    	    return;
        }
    
        //test for server error
    	var newtext = win.document.body.innerHTML;
    	if ( newtext!=null && typeof(newtext)!="undefined" && (newtext!="")) {
    		var controlmsg = newtext.substring(0,10);
    		if (controlmsg == "<br>Server") {
    		    lpOnSendTextFail( lastText, 1);
    		    return;
    		}
        }
    
        var textArray = win.chatLines;
        if(textArray==null) return;
        var lineCount = textArray.length;
        if (lineCount != prevLineCount) {
            prevLineCount = lineCount;
    
            //convert chat array
            var chatLines = new Array();
            for(iline=0;  iline<lineCount;  iline++){
                var jLine = textArray[iline];
                if(jLine.length!=4) continue;
                chatLines[iline] = new LPChatLine( jLine[0], jLine[1], jLine[2], jLine[3] );
            }
            if( lpLastLineIndex != chatLines.length ) {
                lpOnAddLines( chatLines, lpLastLineIndex );
                lpLastLineIndex = chatLines.length;
            }
    
            unsentLine = "";
            // If we have unsent lines because we switched from Java to Javascript - send the next line.
            if (sendingUnsentLines){
                sendUnsentLines();
            }
        }
    
        //push url
        var pushURL = win.pushURL;
        win.pushURL = "";
        if (pushURL != "") {
            lpOnURLPush(pushURL);
        }
    
    	//handle control command
    	var controlCommand = win.controlCommand;
    	win.controlCommand = "";
    	if ((typeof(controlCommand) != "undefined") && (controlCommand != null) && (controlCommand != "")) {
    		handleControlCommand(controlCommand);
    	}
    
    }
    
    <script>
    iframecontent.php:

    Code:
    <?
      Header('Cache-Control: no-cache');
      Header('Pragma: no-cache');
      ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="EN" xml:lang="EN">
    <head>
    
    <link href="./window.css" rel="stylesheet" type="text/css" />
    
    
    <title>Window</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta name="description" content="Live " />
    <meta name="keywords" content="live" />
    <style>
    BODY {
      width:334px
    }
    </style>
    </head>
    <body bgcolor="white" style="margin: 0" onload="scrollwindow()" class="contentWrapper">
    <script type="text/javascript">
    var chatLines = [["I am testing this i frame","Bob","4","1175958864183"],
    ["i do not know how this is working","Bob","1","1175958880480"],
    ["could any one tell me","Bob","1","1175958883949"]
    ];
    function scrollwindow()
    {
    	if ((navigator.appName.indexOf("Netscape") < 0) || (parseInt(navigator.appVersion)>4))
    		scroll(0, 50000);
    }
    
    var wasInChat = true;
    var pushURL = "";
    var controlCommand = "";
    document.controlCommand = controlCommand;
    
    if (navigator.appName.indexOf("Netscape") >= 0)
    	scroll(0, 50000);
    
    </script>
    <noscript><p>
    This functionality requires JavaScript. Please enable JavaScript and try again.
    
    </noscript>
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr>
      <td dir="ltr" class="chatContent">
      	 <div id="chatContentDiv" style="font-size: smaller; font-family: arial, arial, helvetica, geneva;">
    	<span style="color: blue;"><b><span class="OperatorName">Bob: </span></b></span>
    <span style="color: black;"><span class="OperatorText">I am testing this i frame</span><br /></span>
    <span style="color: blue;"><b><span class="OperatorName">Bob: </span></b></span>
    <span style="color: black;"><span class="OperatorText">i do not know how this is working</span><br /></span>
    <span style="color: blue;"><b><span class="OperatorName">Bob: </span></b></span>
    <span style="color: black;"><span class="OperatorText">could any one tell me</span><br /></span>
    
        </div>
      </td>
    </tr>
    </table>
    </body>
    </html>
    Last edited by mehran; 04-10-07 at 10:03.

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    How are you calling getnewdata() ? Are you using a button? I cannot see the button or submit input type in the code you have provided. Have you used firebug (in firefox) to debug your javascript?

  3. #3
    Join Date
    Apr 2005
    Posts
    203
    i am calling getnewdata() using a loop function with timer. This part is doing the submit part it it is kind of new way to do it !!

    var u = "http://localhhost/iframecontent.php?cmd=file&file=chatText&site=6767 89&sessionkey=H7221484707459237529K46228278&d=" + jsGetDate();
    document["lpCommFrame"].location = u;

    i am developing this on IE7 and not sure what debugging tool should i use. I was looking for a debugging tool that is attached to IE7 browser so i could debug live but could not find one!!!
    do you think firebug is good for this purpuse?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •