SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    msxml2.domdocument.6.0 open() error on IE6

    Hi

    I'm having trouble with the open("get", url, false); statement in my ajax routine. It's working in Firefox but not in IE6 (which is the browser my client needs it to run in).

    The error message is : "Object doesn't support this property or method"
    On the http_request.open("GET", url + parameters, false);" line in the code below.

    I'm using Msxml2.DOMDocument.6.0. And got the files on my computer. I also got version 3 on my computer. (Test script showing that both are valid and working/detected from javascript).

    As I understand it, MS want us to use version 6 if possible. And fallback to version 3. If I use "Microsoft.XMLHTTP" instead it works.
    As I understand it, microsoft.xmlhttp works because it's implemented in MSXML3 for legacy support.

    I'm starting to believe that version6 is not supported in IE6, even if it detects it right. But, version 3 should work, but doesn't - only with the old name (microsoft.xmlhttp). Why's that?
    I've also got some other versione (4 and 5 but also some 2 versions) on my computer, so I guess they mess it up for me. So I really don't know what version microsoft.xmlhttp is trigging.


    So, does anyony know what to do?
    I would like to use version 6 because it might make life easier later in the project. But it seems that I can't?

    Here is my ajax code snippet.
    function ele() is called from my html with two parameters.
    The backend file (change.php) is working perfectly, if I give it change.php?loc=2&dat=test it does what it's supposed to to.

    Any help on this one would be nice.

    Code:
       var http_request = false;
       function makeRequest(url, parameters) {
          http_request = false;
          if (window.XMLHttpRequest) { // Mozilla, Safari,...
             http_request = new XMLHttpRequest();
             if (http_request.overrideMimeType) {
             	// set type accordingly to anticipated content type
                http_request.overrideMimeType('text/xml');
                // http_request.overrideMimeType('text/html');
             }
          } else
    	  if (window.ActiveXObject) { // IE
             try {
                http_request = new ActiveXObject("Msxml2.DOMDocument.6.0"); // Microsoft.XMLHTTP
             } catch (e) {
                try {
                   http_request = new ActiveXObject("Msxml2.DOMDocument.3.0");
                } catch (e) {}
             } 
          } 
          if (!http_request) {
             alert('Cannot create XMLHTTP instance');
             // return false;
          }
          http_request.onreadystatechange = alertContents;
          http_request.open("GET", url + parameters, false);
          http_request.send('');
       }
    
       function alertContents() {
    			switch (http_request.readyState){
    			case 4 : try{
    					if (http_request.status == 200) {
    	                        // alert(http_request.responseText);
               					result = http_request.responseText;
    	                    } else {
    				alert('There was a problem with the request.');
    				alert (http_request.status);
    				alert (http_request.statusText);
    	                    };
    					} catch (e) {}
    		}
       }
    	
    	function ele(loc,dat)
    	{
    	var getstr ="?";
    		getstr += "loc=" + loc + "&dat=" + dat;
    		makeRequest('change.php', getstr);
    	}

  2. #2
    SitePoint Member
    Join Date
    Jul 2007
    Location
    Silion Valley
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shouldn't you be using "MSXML2.XMLHTTP.3.0" rather than "Msxml2.DOMDocument.3.0" ?!!
    I've made every mistake and suffered every pain.
    So you don't have to.
    Stuck with JS or AJAX issue? Ask me here.

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much for your answer.

    After trying that one - Yes I should. Cause it now works. Thank you.

    But how should I know that? Where is the documentation for this? I couldn't even find it in the SDK... (I might be blind in there).

    Every place all I can see is that I need to do this :
    "var xmlDOM = new ActiveXObject('Msxml2.DOMDocument.6.0');"

    And not "var xmlDOM = new ActiveXObject('Msxml2.xmlhttp.6.0');"
    So, where does the "domdocument" come from? And when to use it? (if any time/place at all) And why is the "manual" from MS so "stupid" :)

    But again, thank you for giving me the right syntax here.

    EDIT

    Ok, I see it now I think. The domdocument is for loading and holding an xml document for processing, not the "ajax" part.
    Consider this two php lines to be the same (I'm using it to load an xml template file)
    $xml = new DOMDocument;
    $xml->Load('cal.xml');

    And the xmlhttp is for the communication part (the ajax bit).

    Am I right or wrong here now?

  4. #4
    SitePoint Member
    Join Date
    Jul 2007
    Location
    Silion Valley
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by d4rg0 View Post
    Am I right or wrong here now?
    Yes, you got it.
    I've made every mistake and suffered every pain.
    So you don't have to.
    Stuck with JS or AJAX issue? Ask me here.


Bookmarks

Posting Permissions

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