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.

Ajax Pageresults not loaded in IE

134 100+
Hi

i'm having a form which contains 2 list boxes., 1st for category and 2nd for subcategory

the 1st list box contains the category lists., which is displayed from the database.,

and i want to display the corresponding subcategories in the 2nd list box when the category in the 1st listbox is selected.
So i hav called the ajax function in the onchange event of the listbox., and displayed the subcategories in the 2nd list box using xml Http request.,

which works well in firefox but not in IE.,


here is my code


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var id;
  3. var action;
  4.  
  5.  
  6. function ajaxFunction(cat)
  7. {
  8.  
  9. var xmlHttp;
  10. try
  11.   {
  12.   // Firefox, Opera 8.0+, Safari
  13.   xmlHttp=new XMLHttpRequest();
  14.   }
  15. catch (e)
  16.   {
  17.   // Internet Explorer
  18.   try
  19.     {
  20.     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  21.     }
  22.   catch (e)
  23.     {
  24.     try
  25.       {
  26.       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  27.       }
  28.     catch (e)
  29.       {
  30.       alert("Your browser does not support AJAX!");
  31.       return false;
  32.       }
  33.     }
  34.   }
  35. xmlHttp.onreadystatechange=function()
  36.  if(xmlHttp.readyState==4)
  37.  { 
  38.      document.getElementById("change").innerHTML=xmlHttp.responseText;
  39.  }
  40. }
  41.  
  42. xmlHttp.open("GET","categorychange.php?catname="+cat,true);
  43. xmlHttp.send(null);
  44.  
  45. }
  46. function onchangefn()
  47. {
  48.     cat_val=document.form1.category.value;
  49.  
  50.     ajaxFunction(cat_val)
  51. }
  52. </script>
  53.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. //comes inside the table and category names are displayed from the database
  3.  
  4. <select name="category" id="category"  onchange="onchangefn()">
  5. <option selected="selected">[-------------S E L E C T-------------]</option>
  6. <?
  7. $res_cat=$ins->selectquery("select * from category");
  8.  while($line_cat=mysql_fetch_array($res_cat,MYSQL_ASSOC))
  9.  {
  10.  ?>
  11. <option ><? echo $line_cat['catname'];?></option>
  12.  <?
  13.   }
  14.  ?>
  15. </select>
  16.  
<div id="change"></div>



and in my categorychange.php page,by getting the category name the corresponding subcategory'a are selected from database and displayed in the <div>tag specified.,
this is the code in the categorychange.php page.,

Expand|Select|Wrap|Line Numbers
  1. <?
  2. $res_fn=$ins->selectquery("select * from subcategory where catid='$catid'");
  3. $i=0;
  4. ?>
  5. <select name="subcategory">
  6. <option selected="selected">[-------------S E L E C T-------------]</option>
  7. <?
  8. $res_fn=$ins->selectquery("select * from subcategory where catid='$catid'");
  9. while($line_fn=mysql_fetch_array($res_fn,MYSQL_ASSOC))
  10. {
  11. ?>
  12. <option value="<? echo $line_fn['subcatname'];?>"><? echo $line_fn['subcatname'];?></option>
  13. <?
  14. }
  15. ?>
  16. </select>
  17.  

when runs in firefox it works well and the corresponding subcategory name is displayed when the category name is changed.,

but in IE i only get the default option.,

that is. <option selected="selected">[-------------S E L E C T-------------]</option>
no corresponding list is found.,

and even it is not displaying the subcategory list before the list item.,

could anyone help me??

regards
vijay
Apr 16 '08 #1
4 1556
gits
5,390 Expert Mod 4TB
is the corrrect cat sent in the IE case - so that the query is correct and you get the expected results from the database?

kind regards
Apr 16 '08 #2
vjayis
134 100+
is the corrrect cat sent in the IE case - so that the query is correct and you get the expected results from the database?

kind regards

Ya probably i'm sending the correct cat value to the page.,

And even i tested by printing the cat value in ajax page and it worked well even in IE.,
But it is not displaying the results inside a loop. i think so.,

thanks
Apr 16 '08 #3
gits
5,390 Expert Mod 4TB
hmmm ... i don't think that is a javascript problem when you are sure that cat is correct. i tested the following code in IE6 and FF and it worked:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function build_select() {
  3.     var container = document.getElementById('change_div');
  4.  
  5.     var val = '<select><option value="1">1</option>' 
  6.               + '<option value="2">2</option></select>';
  7.  
  8.     container.innerHTML = val;
  9. }
  10. </script>
  11. <body onload="build_select();">
  12.     <div id="change_div"></div>
  13. </body>
  14.  
could you trace the responseText and set the innerText in IE (will not work in FF) this will show you what the responseText is ... is it what you expect to be?

kind regards
Apr 16 '08 #4
vjayis
134 100+
hmmm ... i don't think that is a javascript problem when you are sure that cat is correct. i tested the following code in IE6 and FF and it worked:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function build_select() {
  3.     var container = document.getElementById('change_div');
  4.  
  5.     var val = '<select><option value="1">1</option>' 
  6.               + '<option value="2">2</option></select>';
  7.  
  8.     container.innerHTML = val;
  9. }
  10. </script>
  11. <body onload="build_select();">
  12.     <div id="change_div"></div>
  13. </body>
  14.  
could you trace the responseText and set the innerText in IE (will not work in FF) this will show you what the responseText is ... is it what you expect to be?

kind regards

Hi

thanks
i ll try it out.,
Apr 18 '08 #5

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

Similar topics

2
by: sgmaat | last post by:
I have create a AJAX webpage where if you press a link content is loaded into a div. NOw when this content is loaded no javascript is processed (i.e <Script>alert(..);</script>), but if the...
0
by: arunprabu | last post by:
Hi, I have a problecm with the AJAX request in my webpage. I have some filters on top of the page. I have a submit button and an empty div below the filters. Some of the filters have ajax...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
2
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about...
3
by: radix | last post by:
Hello, I have a aspx page with ajax scriptmanger update panel etc. I also have public string variables on the aspx page. Whenever postback happens from Ajax update panel, at server side all...
18
by: vjayis | last post by:
hi i have a php page in which i have included few tabs links like games, news,entertainment etc., when i click the tablink an ajax page is loaded below. In that ajax page several...
10
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the...
9
bugboy
by: bugboy | last post by:
I have a page being generated with PHP, it includes a DIV who's content gets swapped with ajax. the new content contains the following function call PHP echo'd inside the parent DIV. The code...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.