Jump to content

PM System - IE disfunctionality


Nelak

Recommended Posts

Hi,
Im using ajax as an auto complete for a PM system for my site (www.eve-resource.net) but im having some problems with IE, works perfectally in firefox. Heres the script:

[code]
<script language="javascript">

    function createRequestObject() {
    if (window.XMLHttpRequest) { // Mozilla, Safari, Opera...
        var xmlhttp = new XMLHttpRequest();
        if (xmlhttp.overrideMimeType)
xmlhttp.overrideMimeType('text/xml');
    }
else if (window.ActiveXObject) { // IE
        try {
            var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!xmlhttp) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
return xmlhttp;
  }
   
    // Make the XMLHttpRequest object
    var http = createRequestObject();
   
    function sendRequest(q) {
   
       // Open PHP script for requests
       http.open('get', '/suggest.php?q='+q);
       http.onreadystatechange = handleResponse;
       http.send(null);
   
    }
   
    function handleResponse() {
   
       if(http.readyState == 4 && http.status == 200){
   
          // Text returned FROM the PHP script
          var response = http.responseText;
   
          if(response) {
             // UPDATE ajaxTest content
             document.getElementById("searchResults").style.display = "visible";
             document.getElementById("searchResults").innerHTML = response;
          }
   
       }
   
    }

function setvalue(userid, uname){
  obj = document.getElementById("searchResults");
  obj.style.visibility = "hidden";
  obj.style.display = "none";
 
  document.getElementById("q").value = uname;
  document.getElementById("to").value = userid;
}

    function refresh(){
     
      window.location.reload( false );
     
    }
</script>
[/code]

In firefox uname is put into the visible text box and userid is put into the hidden field, but in IE userid is put into the visible text box and nothing is entered into the hidden field. If someone could help me with this i would be very grateful.

Thanks,
Chris
Link to comment
Share on other sites

For a full answer to what your problem is please enclose any errors from the javascipt/error console in FF or any that you may get IE

Ok first thing that I see is that you are setting the size and height to 0px.. This is not needed. You can simply set the obj.style.display to none. This means that it will not take any space on the page until you set the display to block..

Now as far as the createRequestObject function I think that you should consider using this one.. I have tested it in Safri, FireFox, Netscape, Opera, IE6 and IE7.

[code]
//createRequestObject function thanks to ober
function createRequestObject() {
    if (window.XMLHttpRequest) { // Mozilla, Safari, Opera...
        var xmlhttp = new XMLHttpRequest();
        if (xmlhttp.overrideMimeType)
xmlhttp.overrideMimeType('text/xml');
    }
else if (window.ActiveXObject) { // IE
        try {
            var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!xmlhttp) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
return xmlhttp;
}
[/code]

Also, you may want to consider a more descriptive subject for future posts.

Tom
Link to comment
Share on other sites

[quote author=tomfmason link=topic=121365.msg499140#msg499140 date=1168204620]
For a full answer to what your problem is please enclose any errors from the javascipt/error console in FF or any that you may get IE
[/quote]

How do i get to this? sorry being so unspecific, im new to ajax so therefor dont know what im loking for in terms of errors.

Thanks a lot for your help, i really appreciate it,
Chris
Link to comment
Share on other sites

ok i have enclosed all my cod enow (with your create object script :) thanks!)

i found the firefox console but cudent find the IE 1, but heres some error i got:

Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: http://www.nelak.net/user/pm.php?a=new :: handleResponse :: line 40"  data: no]
Source File: http://www.nelak.net/user/pm.php?a=new
Line: 40

Error: uncaught exception: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]"  nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)"  location: "JS frame :: http://www.nelak.net/user/pm.php?a=new :: sendRequest :: line 34"  data: no]

Error: not well-formed
Source File: http://www.nelak.net/suggest.php?q=Ne
Line: 8, Column: 35
Source Code:
// add a zero in front of numbers<10----------------------------------^

Warning: Error in parsing value for property 'display'.  Declaration dropped.
Source File: http://www.nelak.net/user/pm.php?a=new
Line: 0


this worries me a lot as its a fair few errors :-/

thanks again,
Chris
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.