XmlHttpRequest()

Anything and everything related to programming in the Win32 platform.

XmlHttpRequest()

Postby Hieran_Del8 » Sat Jul 24, 2010 1:36 pm

I'm trying to get online documentation running for a project I'm working on, but it doesn't seem to be working in ie8, though it's working in mozilla 3.

The functions are related to XmlHttpRequest. I know ie use to use ActiveXObject, but now it seems to be supporting XmlHttpRequest now.

Anyway, my function calls are:
Code: Select all
function OpenXmlRequest() {
    var request = false;
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return request;
}

function ProcessXml(xmlReq, div) {
    if (xmlReq.readyState == 4) {
        if (xmlReq.status == 200) {
            div.innerHTML = xmlReq.responseText;
        }
        else {
            div.innerHTML = "<p>Failed to load!</p>";
        }
    }
}

function LoadXml(url, div) {
    var request = OpenXmlRequest();
    if (request) {
        request.open('GET', url, true);
        request.setRequestHeader("If-Modified-Since", Date());
        request.onreadystatechange = function() { ProcessXml(request, div); };
        request.send("");
    }
}

In the webpage, I call something like 'LoadXml("dsdx_doc_reference_interfaces.txt", this);' in an event handler. In Mozilla, it's working every time. In ie8, it works once, but fails on subsequent calls. Any ideas?

Here's the webpage:http://dsdxlibrary.sourceforge.net/documentation/dsdx_docs.htm
Image
User avatar
Hieran_Del8
Most Valuble Contributor
 
Posts: 349
Joined: Thu Nov 06, 2008 4:59 am
Location: Marengo, IL

Re: XmlHttpRequest()

Postby Lonewolff » Sat Jul 24, 2010 2:37 pm

Hi Hieran_del8,

What is is meant to do?
Image
User avatar
Lonewolff
Site Admin
 
Posts: 268
Joined: Thu Oct 30, 2008 3:40 pm

Re: XmlHttpRequest()

Postby Hieran_Del8 » Sun Jul 25, 2010 11:57 am

I have a simple web page that loads a list of topics from a file "dsdx_doc.txt". This file contains html code to organize text into divisions with id's, and event callbacks for onmouseover, onmouseout, and onclick. Here's a snippet:
Code: Select all
<div id="doc_intro" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Introduction to the DSDX Library</div>

<div id="doc_about" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">About the DSDX Library</div>

<div id="doc_using" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Using the DSDX Library</div>
   <ul>
   <li id="doc_using_register" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Registering and Unregistering the COM renderers</li>
   <li id="doc_using_create" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Creating and Destroying the renderers</li>
   <li id="doc_using_query" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Querying the target renderers</li>
   <li id="doc_using_require" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Requirements for stable video rendering</li>
   </ul>


The page is also responsible for loading a body of text related to the topic selected. For instance, if the heading "Using the DSDX Library" is selected (as seen in above code), then the page would load the content related, namely a description on using the library.

The "onclick" event handler calls the function LoadContent(), passing the element it is being called from as argument (or "this"). Internally, the element's id is extracted and is used to determine the file from which to load contents.
Code: Select all
function LoadContent(srcDiv) {
    var destDiv = document.getElementById("contents");
    var id = srcDiv.getAttribute("id"); //id extracted from srcDiv
    var fileName = "dsdx_" + id + ".txt"; //file name figured
    LoadXml(fileName, destDiv);
}
In other words, if the division of id "doc_using" is selected, the file "dsdx_doc_using.txt" is retrieved for processing.

The contents of the requested file are written to another part of the page, under the element with id "contents". The files generally carry just html, such as "dsdx_doc_using.txt":
Code: Select all
<h1>Using the DSDX Library</h1>
<p>This section describes in detail the steps required to use the DSDX Library in an application.</p>
<p>There are nine steps to using the library within an application. They are:</p>
<ol>
<li>Register the library with the system</li>
<li>Create an instance of the renderer</li>
<li>Connect the renderer to a filter graph and run the graph</li>
<li>Present the media samples</li>
<li>Use the target resources in the app</li>
<li>Repeat steps 4 and 5 for the duration of the app</li>
<li>Close the filter graph</li>
<li>Destroy the instance of the renderer</li>
<li>Unregister the library with the system</li>
</ol>
<p>The following articles detail these processes more specifically.</p>

<p>Registering and Unregistering the COM renderers</p>

<p>Creating and Destroying the Renderers</p>

<p>Querying the Target Renderers</p>

<p>Requirements for Stable Video Rendering</p>
Image
User avatar
Hieran_Del8
Most Valuble Contributor
 
Posts: 349
Joined: Thu Nov 06, 2008 4:59 am
Location: Marengo, IL

Re: XmlHttpRequest()

Postby Hieran_Del8 » Sun Jul 25, 2010 3:14 pm

Never mind. I've obtained the excessively useful javascript library jQuery. Wow, I didn't think coding in javascript would get this incredibly easy! And using this library fixed my problems!!! Woo hoo!! :D
Image
User avatar
Hieran_Del8
Most Valuble Contributor
 
Posts: 349
Joined: Thu Nov 06, 2008 4:59 am
Location: Marengo, IL

Re: XmlHttpRequest()

Postby lp rob1 » Thu Jul 29, 2010 3:57 am

Don't rely on IE working properly... it's made by Microsoft :lol:
But seriously, IE has been known not to display web pages properly or implement standards properly. So don't worry if something works in Firefox, but not in IE. It is IE's problem. In the ideal world IE wouldn't exist and Microsoft would become open source. :D
User avatar
lp rob1
Veteren
 
Posts: 124
Joined: Tue Jan 12, 2010 6:34 am
Location: England, UK

Re: XmlHttpRequest()

Postby Lonewolff » Thu Jul 29, 2010 7:34 am

The word on the street is that IE8 is now more compliant with web standards than Firefox is.

But, whenever I create any type of web page/app, I make sure I it views the same between the two browsers. Because, you often get caught out. ;)
Image
User avatar
Lonewolff
Site Admin
 
Posts: 268
Joined: Thu Oct 30, 2008 3:40 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest