Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
|
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2007, 09:49 AM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to broomie
Default hiddenFrame has no properties error

Folks,

I've bought the Ajax Pro book from Wrox and been running through the examples. I don't code much these days but wanted to familiarize myself with Ajax.
Almost straight away I cam off the rails sadly!

Firstly I did my own code and got the erros then I copied them out of the downloaded code and got the same. I've tried Firefix, Mozilla and IE and get the same error.

The essence of the Exercise in Chapter 2 basics is to query a very simple mySQL DB table and return the results to the same page (hidden Frame) you entered the queries from.

Heres my Display.html code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    <title>Customer Account Information</title>
    <script type="text/javascript">
        function requestCustomerInfo() {
            var sId = document.getElementById("txtCustomerId").value;
                        top.frames["hiddenFrame"].location = "GetCustomerData.php?id=" + sId;
        }

        function displayCustomerInfo(sText) {
            var divCustomerInfo =document.getElementById("divCustomerInfo");
            divCustomerInfo.innerHTML = sText;
        }
    </script>
</head>
<body>
    <p>Enter customer ID number to retrieve information:</p>
    <p>Customer ID: <input type="text" id="txtCustomerId" value="" /></p>
    <p><input type="button" value="Get Customer Info" onclick="requestCustomerInfo()" /></p>
    <div id="divCustomerInfo"></div>
</body>
</html>

Heres my hidden page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>hidden Frame Example 1</title>
</head>
<frameset rows="100%,0" frameborder="0">
    <frame name="displayFrame" src="display.htm" noresize="noresize" />
            <frame name="hiddenFrame" src="about:blank" noresize="noresize" />
</frameset>
</html>

Problem: When I enter say Cust ID "1" I get "top.frames.hiddenFrame has no properties" in Java script console. Nothing is dispalyed at all in the hidden frame below the query box (as it does in the example Chapter 2 Professional Ajax) DB seems sound and has error messages built in if this was getting upset in any way

PHP call to DB:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Get Customer Data</title>
<?php

    //customer ID
    $sID = $_GET["id"];

    //variable to hold customer info
    $sInfo = "";

    //database information
    $sDBServer = "localhost";
    $sDBName = "AjaxDB";
   // $sDBUsername = "root";
   // $sDBPassword = "null";

    //create the SQL query string
    $sQuery = "Select * from Customers where CustomerId=".$sID;

    //make the database connection
    $oLink = mysql_connect($sDBServer,$sDBUsername,$sDBPassword );
    @mysql_select_db($sDBName) or $sInfo = "Unable to open database";

    if($sInfo == '') {
        if($oResult = mysql_query($sQuery) and mysql_num_rows($oResult) > 0) {
            $aValues = mysql_fetch_array($oResult,MYSQL_ASSOC);
            $sInfo = $aValues['Name']."<br />".$aValues['Address']."<br />".
                     $aValues['City']."<br />".$aValues['State']."<br />".
                     $aValues['Zip']."<br /><br />Phone: ".$aValues['Phone']."<br />".
                     "<a href=\"mailto:".$aValues['E-mail']."\">".$aValues['E-mail']."</a>";
        } else {
            $sInfo = "Customer with ID $sID doesn't exist.";
        }
    }

    mysql_close($oLink);

?>

    <script type="text/javascript">
        window.onload = function () {
            var divInfoToReturn = document.getElementById("divInfoToReturn");
            top.frames["displayFrame"].displayCustomerInfo(divInfoToReturn.innerHTML);
        };

    </script>

</head>
<body>
    <div id="divInfoToReturn"><?php echo $sInfo ?></div>
</body>
</html>


I've tried some remedies like placing "parent" and "Window" in various places as recommended but to no avail. Sorry if this is a very basic schoolboy error.


many thanks for your time


Paul
 
Old April 20th, 2007, 05:51 PM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you ever resolve this problem.

I seem to have run into the same thing.

I set up a new directory and reloaded the example code from scratch - no luck.

If you have any solution can you post it here or send an email to:

[email protected]

Thanks

 
Old May 18th, 2007, 11:30 AM
Authorized User
 
Join Date: May 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to firebirdjohn61
Default

I had some problems here too. But then I rewrote the whole thing for adjusting it to Firebird 2.0. It works now - just fine - even though I had some problems. I forgot to bring along all the functions I had in PHP to access the database in Firebird 2.0.

First you need to debug:
Change the <frameset rows="100%,0" frameborder="0">
to <frameset rows="50%,50%" frameborder="0">
It will make you see what's happening in the hidden frame that will now bee seen. All error messages will be shown and so will your own messages also as echo "Need to know right know <br />

Best of luck.
 
Old August 31st, 2007, 06:07 AM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to broomie
Default

I got this to work as explained by Firebird by reducing 100% to 50%,50%!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Interrogating Properties tclancy C# 0 January 11th, 2007 09:41 AM
properties aadz5 C# 3 December 29th, 2003 11:38 AM
Properties robert_83 .NET Web Services 0 July 30th, 2003 07:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.