Closed Bug 306679 Opened 19 years ago Closed 19 years ago

calling function, which use XMLHttpRequest, from other frame results in error

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: papa200480, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.10) Gecko/20050717 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.10) Gecko/20050717 Firefox/1.0.6

Suppose, I have 2 frames: top & bottom.
There is function refresh() in bottom frame, which use XMLHttpRequest.

If I call function refresh from top frame, "Component returned failure code:
0x80040111 (NS_ERROR_NOT_AVAILABLE)" error occures when I get
XMLHttpRequest.status property.

Reproducible: Always

Steps to Reproduce:
1. 2 frames:
main page:
<html>
   <frameset rows="*, 100" id='TaskFrame'>
        <frame src="/index.html" name="top" />
        <frame src="basket_frame.jsp" id='bottom' name="bottom" />
   </frameset>
</html>

top frame:
<html>
    <script type="text/javascript">
        function load() {
            parent.frames['bottom'].refresh();
        }
    </script>
  <body onload='javascript:load()'></body>
</html>

bottom frame:
<html>
...
<script>
...
        function refresh() {
            doRequest('/ajax/basket.jsp');
        }

        function doRequest(url) {
            if (window.XMLHttpRequest) {
                req = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            }
            req.onreadystatechange = processRequest;
            req.open("GET", url, true);
            req.send(null);
        }

        function processRequest() {
            if (req.readyState == 4) {
                if (req.status == 200) { parseMessages(); }
                else if (req.status==999){
                    window.parent.location = "/index.html";
                }
            }
        }

        function parseMessages() { ... }
...
</html>
2. load main page

Actual Results:  
refresh() method is called, but there is an error in JS console:
Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]

so parseMessages() is never called.

Expected Results:  
parseMessages() have to be executed.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.