473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why is ajax code not working in IE8?

abquader
I hv written following a code in ajax

Expand|Select|Wrap|Line Numbers
  1.  
  2. var xmlHttp;
  3.  
  4. function typeChanged(str){
  5.  
  6.     if(window.XMLHttpRequest){
  7.         xmlHttp=new XMLHttpRequest();
  8.     }else{
  9.         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  10.     }
  11.     var allTypes="";
  12.     xmlHttp.onreadystatechange=function(){
  13.         if(xmlHttp.readyState==4 && xmlHttp.status==200 ){
  14.             document.getElementById('sNames').innerHTML=xmlHttp.responseText;
  15.         }
  16.     }
  17.  
  18.     xmlHttp.open("GET","process.jsp?str="+str,true);
  19.     xmlHttp.send();
  20.  
  21.  
  22. }
  23.  
  24.  
This is a javascript function called on onchange event of a combobox.

This code works fine in firefox but doesnot work in IE8
In IE8, the values don't get displayed as they r taken from server in a jsp as can b seen

plz suggest me if thr is any change

thnx in advance
Feb 9 '11 #1
9 11133
acoder
16,027 Expert Mod 8TB
Do you get any errors? Perhaps the response is being cached.

Try adding a unique timestamp to eliminate caching. Also, check that you're passing the correct value by checking the function call. You should also check the output from process.jsp
Feb 10 '11 #2
Have a look :

xmlhttprequest-not-working-with-all-browser thread on stackoverflow
Feb 11 '11 #3
hay sarang, thnx for ur reference but i couldnot understand from it.
one thing i must say is that i m not using jquuery
plz check whether thr is any other solution
Feb 11 '11 #4
acoder
16,027 Expert Mod 8TB
The link posted was the answer to a different problem. process.jsp is obviously from the same domain.

@abquader: have you tried any of the suggestions I posted?
Feb 15 '11 #5
Frinavale
9,735 Expert Mod 8TB
A while ago I implement a script that retrieved an appropriate XMLHttpRequest for IE based on legitimate XMLHttpRequest versions (at the time).

It's been a while since I've used it or tried playing with it...but this is the code that I had posted previously for the task:

Expand|Select|Wrap|Line Numbers
  1. function GetXmlHttp()
  2. {   /*This function is responsible for creating an HttpRequest object 
  3.       based on the browser that the user is currently using. */
  4.   var xmlHttp = null;            
  5.   try
  6.   {   //Mozilla, Opera, Safari etc.
  7.     xmlHttp=XMLHttpRequest();
  8.   }catch(e)
  9.   {   //Internet Explorer uses ActiveX objects to make Ajax calls.
  10.       //the following are valid versions, here we will loop through 
  11.       //the versions and attempt to create the ActiveX that matches the browser.
  12.     var versionIds = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0",
  13.         "Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0", 
  14.         "Msxml2.XMLHTTP.2.6","Microsoft.XMLHTTP.1.0", 
  15.         "Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];
  16.     for(var i=0; i<versionIds.length && xmlHttp == null; i++) 
  17.     {
  18.       xmlHttp = CreateXmlHttp(versionIds[i]);
  19.     }
  20.   }
  21.   return xmlHttp;
  22. }
  23.  
  24. function CreateXmlHttp(id) 
  25. {   /*Creates an ActiveX object used by Internet Explorer that will make Ajax calls*/
  26.     var xmlHttp = null;
  27.     try 
  28.     {
  29.       xmlHttp = new ActiveXObject(id);
  30.     }catch(e) {}
  31.     return xmlHttp;
  32. }
-Frinny
Feb 16 '11 #6
hay Frinny,
thnx for ur suggestion bt it didn't work for me
it is still showing the same error "Object expected"
Feb 26 '11 #7
Frinavale
9,735 Expert Mod 8TB
I typically see that error if I am trying to call a function that does not exist.

If you are using Internet Explorer 8 then you should consider using the debugger that comes built into it to find out where this error is occurring. Likewise, if you're using Chrome or Safari, use the built in debuggers. If you're using FireFox, then consider downloading FireBug to help you debug your JavaScript problems.

-Frinny
Feb 27 '11 #8
hi, there is nothing wrong with the code you show. it is probably in the way you built your option box. the (str) you send to your function typeChanged is probably the this.value of an option. you may not have set the value of the option box like <option value="yourvalue" ><yourvalue></option>. although all the other browsers assume the value if not stated, IE8 does not. i had exactly the same issue and rewrote code many times. it was frustrating because i was looking at the wrong thing. so glad this worked for me.
Mar 2 '12 #9
Thanks Frinny, your cod eworks like a charm for my ajax instance which was worked on IE 6 but not on IE 8 (and perhaps IE 7). I though all IE have same version Id for their xmlhttp agents, but now I know I was wrong. I forgot the fact that MS is always happy with their version incompatibility...lol
Nov 8 '12 #10

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

Similar topics

3
by: nuchphasu | last post by:
Hi I have a problem on Dropdownlist that connect database and retrieve data by Ajax.I write javascript like this -------------------------------------------------------------------------...
8
by: jd2007 | last post by:
Why the Ajax code below in ajax.js is causing my form not to work ? ajax.js: var a=0; var b=0; var c=0; var d=0; var e=0; var f=0;
1
VijaySofist
by: VijaySofist | last post by:
Hai All! Is it possible to draw some simple simple structures (like line, square,circle) using AJAX code. If possible can anybody send the code. I want to use this code in ASP.NET. Thanks in...
1
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped...
5
by: krishna.tunikipati | last post by:
Hi I have updated my firefox browser from 2.0 to 3.0 My AJAX functionality is not working in firefox3.0 But in firefox2.0 it worked fine. and working fine in all IE versions Plz give me a...
6
by: =?Utf-8?B?RGFuaWVs?= | last post by:
Hi, I'm building a site with Visual Studio 2008 utilizing ajax extension. The page works fine on IE7/FireFox, but on IE6, each action on the page will cause an entire page refresh. Basically the...
22
by: canabatz | last post by:
Hi all! i got a countdown timer for auctions that runing. i got a DIV that refreshs every 4 seconds that DIV is refreshed by ajax ,the file that is refreshed is timer.php for example!! my...
1
maliksleo
by: maliksleo | last post by:
hi all i configured my website on my local server after some time the ajax stop working on all pages and shows error on page in the left bottom when clicked it shows sys is undefined waiting...
1
by: waqasmgl | last post by:
Hi, I m confused about following ajax code. Where is the problem? Working good on IE but not on FireFox? Please sort it out. <script type="text/javascript"> function loadXMLDoc() { if...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.