Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ajax Programming

Problem with IE


At the moment I'm trying to get data from a different server, however
since this is not possible when using ajax (if requesting xml) I have
a script in php that does the request from my own server. When I do my
ajax request in Firefox everything works and I can see the data which
is returned by the request however it doesn't work in IE. My script:

function makeRequest(d,e) {
        var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                        // See note below about this line
        } else if (window.ActiveXObject) { // IE
                try {
                        http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                        try {
                                http_request = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (e) {}

        if (!http_request) {
                alert('Giving up :( Cannot create an XMLHTTP instance');
                return false;

        var url = 'the WORKING url here';
        http_request.onreadystatechange = function()
{ get_data(http_request); };
        http_request.open('GET', url, true);


function get_data(http_request) {
        if(http_request.readyState == 1){
                var body = document.getElementsByTagName('body')[0];
                var loading = document.createElement('p');
                var loadText = document.createTextNode('Loading...');

                loading.className = 'load';
                loading.style.position = 'absolute';
                loading.style.left = '50%';
                loading.style.top = '50%';
                loading.style.width = '150px';
                loading.style.display = 'block';
                loading.style.backgroundColor = '#fff';
                loading.style.borderColor = '#aaf';
                loading.style.borderStyle = 'solid';
                loading.style.borderWidth = '2px';
                loading.style.textAlign = 'center';
                loading.style.padding = '5px';
                loading.style.color = '#aaa';


        if (http_request.readyState == 4) {
                var body = document.getElementsByTagName('body')[0];
                for(i = 0; i < body.childNodes.length; i++){
                        if(body.childNodes[i].className == 'load'){
                                node = body.childNodes[i];

                // for-statement below seems to be needed since it doesn't always
work with one
                for(i = 0; i < body.childNodes.length; i++){
                        if(body.childNodes[i].className == 'load'){
                                node = body.childNodes[i];

                if (http_request.status == 200) {
                        var xmlDoc = http_request.responseXML;

                        var a = document.getElementById('a');
                        var b = document.getElementById('b');
                        var c = document.getElementById('c');

                        a.value = xmlDoc.getElementsByTagName('a')[0].firstChild.nodeValue;
                        b.value = xmlDoc.getElementsByTagName('b')[0].firstChild.nodeValue;

                } else {
                        alert('There was a problem with the request.');


Can anybody tell me why it is not working in IE?

Another question:
Is there for IE something like there is for Firefox that shows the
request and returned data and an error if something goes wrong? (It's
an extension in FF)

status and statusText


On 2/2/07, Yorian <yorianbenja@hotmail.com> wrote:

Hey Eric,

Thanks for your reply. After doing some testing I found out that both
(IE and FF) return OK. So the request is actually fully functional.
However I did found out that the problem apparently has something to
do with the var xmlDoc (which contains http_request.responseXML) in FF
this works just fine but in IE it returns object expected.

I myself don't see the problem, does anyone of you do?

Thanks for the help so far.

On Feb 3, 3:13 am, "Eric Pascarello" <alienf@gmail.com> wrote:

On Feb 3, 9:48 am, "Yorian" <yorianbenja@hotmail.com> wrote:

I think IE has more of a problem with malformed XML than firefox does,
so if you're having a problem there, you should probably check out the
XML syntax. If it's possible (and it should be) try loading the XML
file directly in IE and see whether it complains. If it does, you know
it's that, otherwise it's more likely to be your code.

As for your question re XHRs and IE, Fiddler (http://
www.fiddlertool.com/fiddler/) kinda does what you want. It's a little
overly-complex for monitoring XHRs, as it monitors all http winsock (I
think?) traffic - as it tells you when other windows components are
accessing an http socket... like the adverts on msn I think.

Anyway, yeah, check out the validity of the XML and check out fiddler
for http sniffing...

Hope this helps,



Sometimes char encoding (utf-8, euc-kr, and so on) can be a problem in
parsing XML format.
You'd better check it. :-)
Good luck.

Sun-Gi Hong


It isn't the XML, that should be fine, check it yourself:


I might try using Json because of a few reasons but if possible I
would still like to get this working

On Feb 7, 9:11 am, "robotian" <sungi.h@gmail.com> wrote:

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc