469,313 Members | 2,340 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

getting error in IE6

Hello all,

I am using javascript and ajax.
i had writen the following javascript code. which runs fine with firefox but it is not work in Internet Explorer 6.0 tell me whats the problem.

the java script code is as below
Expand|Select|Wrap|Line Numbers
  1. function checkfortasks(url,id)
  2.         {
  3.              var httpRequest;
  4.             if (window.XMLHttpRequest) 
  5.             { 
  6.                 // Mozilla, Safari, ...
  7.                 httpRequest = new XMLHttpRequest();
  8.                 if (httpRequest.overrideMimeType) 
  9.                 {
  10.                     httpRequest.overrideMimeType('text/xml');
  11.                 }
  12.             } 
  13.             else if (window.ActiveXObject) 
  14.             { // IE
  15.                 try 
  16.                 {
  17.                     httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
  18.                 } 
  19.                 catch (e) 
  20.                 {
  21.                     try 
  22.                     {
  23.                         httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  24.                     } 
  25.                     catch (e) {}
  26.                 }
  27.             }
  28.             if (!httpRequest) 
  29.             {
  30.                 alert('Giving up :( Cannot create an XMLHTTP instance');
  31.                 return false;
  32.             }
  33.             httpRequest.onreadystatechange = function() 
  34.             {
  35.                 if (httpRequest.readyState == 4) 
  36.                 {
  37.                     try
  38.                     {
  39.                     document.getElementById(id).innerHTML=(httpRequest.responseText);
  40.                     }
  41.                     catch(ex)
  42.                     { //alert(ex.message);
  43.                     }
  44.                 }
  45.             }
  46.             httpRequest.open('GET',url, true);
  47.             httpRequest.send(null);
  48.  
  49.             theObject = document.getElementById(id);
  50.             theObject.style.visibility = "visible";
  51.             theObject.style.height="8px";
  52.             theObject.style.width="200px";
  53.             var posx = 0;
  54.             var posy = 0;
  55.             theObject.style.left = posx + "px"; 
  56.             theObject.style.top = posy + "px"; 
  57.         }
  58.  
and the html code from where i am calling the js function is as below.

Expand|Select|Wrap|Line Numbers
  1.   <td>
  2.     <img src="image/flakes.jpg" onClick="checkfortasks('flakes.php','fill');" title="Click here To add Flakes" onMouseOver="hover(this);" onMouseOut="hout(this);"/>
  3.   </td>
  4.  
please tell me where i had done mistake!!
Thanks.
Oct 16 '07 #1
8 1513
acoder
16,027 Expert Mod 8TB
What error message are you getting and on what line?
Oct 16 '07 #2
What error message are you getting and on what line?
Hi,

I am getting error: Object Expected
at from where the function called i mean from html.
thanks for reply.
Oct 16 '07 #3
acoder
16,027 Expert Mod 8TB
Can you show the code for the element with id "fill"?

Have you checked that it isn't the mouse events?

I suggest you move the
Expand|Select|Wrap|Line Numbers
  1. var httpRequest
on line 3 to outside the function to make it global.
Oct 16 '07 #4
Hi,

This is my html code, i had also used div instead of span but facing the same problem. Error: Object Expected. also tried withe global httpRequest variable.

Expand|Select|Wrap|Line Numbers
  1. <body>
  2.     <form name="Show" action="" method="post">
  3.         <table> 
  4.             <tr> 
  5.                 <td>
  6.                     <img src="image/flakes.jpg" onClick="javascript: checkfortasks('flakes.php','fill');" title="Click here To add Flakes" onMouseOver="hover(this);" onMouseOut="hout(this);"/>
  7.                 </td>
  8.               </tr>
  9.             <tr>
  10.                 <td>
  11.                     <span id="fill">
  12.                     </span>
  13.                 </td>
  14.             </tr>
  15.         </table>            
  16.  
  17.   <div id='con1' style="position: relative;"></div>
  18.  
  19.   <div id='con2' style="position: relative;"></div> 
  20.             <script language="javascript">
  21.                 var acon1=document.getElementById("con1");
  22.                 Drag.init(con1,null,0,600,0,600);
  23.                 var acon2 = document.getElementById("con2");
  24.                 Drag.init(acon2, null,0,600,0,600);
  25.             </script>    
  26.     </form>
  27. </body>
  28.  
Thanks for spending time for me.
Oct 17 '07 #5
acoder
16,027 Expert Mod 8TB
So does the error occur when you click on the image?
Oct 17 '07 #6
So does the error occur when you click on the image?
Yes dear i am facing the error while click on image.
the same code running in mozila firefox without facing any type of error but dont know how it get error in IE.
so please......
Oct 18 '07 #7
Thanks for your help,,

Now i have got the solution for it.
i just remove the form and table, tr, td tag from the main page that i had posted before. now it works fine for me in mozila firefox and IE6.


Mayur.
Oct 18 '07 #8
acoder
16,027 Expert Mod 8TB
Now i have got the solution for it.
i just remove the form and table, tr, td tag from the main page that i had posted before. now it works fine for me in mozila firefox and IE6.
Interesting. Well, good to see that you got it working.
Oct 18 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.