I'm having problem with this code why i don't know works fine in Internet Explorer only that is my code: - <script language="javascript" type="text/javascript">
-
function AJAX(num){
-
XMLObject = false;
-
if (window.XMLHttpRequest) { // Mozilla, Safari,...
-
XMLObject = new XMLHttpRequest();
-
if (XMLObject.overrideMimeType) {
-
XMLObject.overrideMimeType('text/xml');
-
}
-
} else if (window.ActiveXObject){ // IE
-
try {
-
XMLObject = new ActiveXObject("Msxml2.XMLHTTP");
-
} catch (e) {
-
try {
-
XMLObject = new ActiveXObject("Microsoft.XMLHTTP");
-
}catch (e) {
-
-
}
-
}
-
}
-
if (!XMLObject) {
-
alert('Cannot create XMLHTTP instance');
-
return false;
-
}
-
XMLObject.open("GET","XML.php");
-
XMLObject.onreadystatechange=function(){
-
if(XMLObject.readyState==4 && XMLObject.status==200){
-
var XMLFILE=XMLObject.responseXML;
-
makeList(XMLFILE,num);
-
}
-
}
-
XMLObject.send(null);
-
}
-
function makeList(XMLData,num){
-
var firstCategory=XMLData.documentElement.firstChild;
-
var AllMenus=firstCategory.getElementsByTagName("Menu");
-
var firstMenu=AllMenus[num];
-
for(i=0;i<document.getElementById("Menu").options.length;i++){
-
document.getElementById("Menu").options[i]= null;
-
}
-
for(i=0;i<firstMenu.childNodes.length;i++){
-
document.getElementById("Menu").options[i]=new Option(firstMenu.childNodes[i].firstChild.nodeValue);
-
}
-
}
-
function makeData(what){
-
return what.selectedIndex;
-
}
-
</script>
4 3058 gits 5,390
Expert Mod 4TB
hi ...
what error do you get, if one? or could you please tell what is not working?
kind regards
that is the error i got :
firstCategory.getElementsByTagName is not a function
gits 5,390
Expert Mod 4TB
hi ...
could you post what you get from: - var firstCategory=XMLData.documentElement.firstChild;
may be there is a whitespace-problem in your xml-document? try to refer the first element another way ... through tagName or something like that.
kind regards
That is my HTML page:
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
function AJAX(num){
XMLObject = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
XMLObject = new XMLHttpRequest();
if (XMLObject.overrideMimeType) {
XMLObject.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject){ // IE
try {
XMLObject = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
XMLObject = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e) {
}
}
}
if (!XMLObject) {
alert('Cannot create XMLHTTP instance');
return false;
}
XMLObject.open("GET","XML.php");
XMLObject.onreadystatechange=function(){
if(XMLObject.readyState==4 && XMLObject.status==200){
var XMLFILE=XMLObject.responseXML;
makeList(XMLFILE,num);
}
}
XMLObject.send(null);
}
function makeList(XMLData,num){
var firstCategory=XMLData.documentElement.firstChild;
var AllMenus=firstCategory.getElementsByTagName("Menu" );
var firstMenu=AllMenus[num];
for(i=0;i<document.getElementById("Menu").options. length;i++){
document.getElementById("Menu").options[i]= null;
}
for(i=0;i<firstMenu.childNodes.length;i++){
document.getElementById("Menu").options[i]=new Option(firstMenu.childNodes[i].firstChild.nodeValue);
}
}
function makeData(what){
return what.selectedIndex;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="p ost" action="">
<select name="Category" id="Category" onchange="AJAX(makeData(this))">
<option>Cameras & Photo</option>
<option>Consumer Electronics</option>
<option>Jewelry & Watches</option>
<option>Real Estate</option>
</select>
<select name="Menu" id="Menu" onchange="">
<option>- Choose -</option>
</select>
</form>
</body>
</html>[/HTML]
and that is my XML File:
[PHP]<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("content-type:text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<Commercila>
<CamerasAndPhotos>
<Menu type='Bags, Cases & Straps'>
<subMenu>For Camcorders</subMenu>
<subMenu>For Cameras</subMenu>
</Menu>
<Menu type='Binoculars & Telescopes'>
<subMenu>Binoculars & Monoculars</subMenu>
<subMenu>Eyepieces & Telescope Accs.</subMenu>
<subMenu>Telinoculars & Telescopesescopes</subMenu>
</Menu>
<Menu type='Camcorder Accessories'>
<subMenu>Accessories</subMenu>
<subMenu>Batteries & Chargers</subMenu>
<subMenu>Blank Tapes & Memory</subMenu>
<subMenu>Cables, Cords & Connectors</subMenu>
<subMenu>Lenses & Accessories</subMenu>
</Menu>
<Menu type='Camcorders'>
<subMenu>8mm, Hi8, VHS</subMenu>
<subMenu>Digital 8</subMenu>
<subMenu>DVD</subMenu>
<subMenu>HDD</subMenu>
<subMenu>HDV</subMenu>
<subMenu>MicroMV</subMenu>
<subMenu>MiniDV</subMenu>
<subMenu>Other Digital Formats</subMenu>
</Menu>
<Menu type='Digital Camera Accessories'>
<subMenu>Accessories</subMenu>
<subMenu>Batteries & Chargers</subMenu>
<subMenu>Cables, Cords & Connectors</subMenu>
<subMenu>Digital Photo Frames</subMenu>
<subMenu>Memory Cards</subMenu>
<subMenu>Memory Card Adapters & Readers</subMenu>
</Menu>
<Menu type='Digital Cameras'>
<subMenu>Point & Shoot</subMenu>
<subMenu>Digital SLR</subMenu>
<subMenu>Specialty Digital Cameras</subMenu>
<subMenu>Parts & Repair</subMenu>
<subMenu>Other Digital Cameras</subMenu>
</Menu>
<Menu type='Film'>
<subMenu>16MM</subMenu>
<subMenu>35MM</subMenu>
<subMenu>APS</subMenu>
<subMenu>Medium, Large Format</subMenu>
<subMenu>Polaroid & Instant Print</subMenu>
<subMenu>Processing & Other</subMenu>
</Menu>
<Menu type='Film Camera Accessories'>
<subMenu>Cables, Cords & Connectors</subMenu>
<subMenu>Camera Body Accessories</subMenu>
<subMenu>Remotes & Wireless</subMenu>
<subMenu>Other Film & Movie Accessories</subMenu>
</Menu>
<Menu type='Film Cameras'>
<subMenu>35mm Point & Shoot</subMenu>
<subMenu>35mm Rangefinder</subMenu>
<subMenu>35mm SLR</subMenu>
<subMenu>APS</subMenu>
<subMenu>Cameras for Kids</subMenu>
<subMenu>Disposable</subMenu>
<subMenu>Instant Print, Polaroid</subMenu>
<subMenu>Large Format</subMenu>
<subMenu>Medium Format</subMenu>
<subMenu>Movie</subMenu>
<subMenu>Parts & Repair</subMenu>
<subMenu>Submini, Disc, 110</subMenu>
<subMenu>Underwater</subMenu>
<subMenu>Other Film Cameras</subMenu>
</Menu>
<Menu type='Film Processing & Darkroom'>
<subMenu>Chemistry</subMenu>
<subMenu>Enlargement Equip. & Supplies</subMenu>
<subMenu>Finishing Equipment</subMenu>
<subMenu>Hardware, Lighting & Setup</subMenu>
<subMenu>Loupes & Magnifiers</subMenu>
<subMenu>Photographic Paper</subMenu>
<subMenu>Processing Equipment</subMenu>
<subMenu>Other Darkroom Equipment</subMenu>
</Menu>
<Menu type='Flashes & Accessories'>
<subMenu>Digital Camera Flash Units</subMenu>
<subMenu>Film Camera Flash Units</subMenu>
<subMenu>Flash Accessories</subMenu>
</Menu>
<Menu type='Lenses & Filters'>
<subMenu>Digital Camera Lenses</subMenu>
<subMenu>Film Camera Lenses</subMenu>
<subMenu>Filter Accessories</subMenu>
<subMenu>Filters</subMenu>
<subMenu>Lens Accessories</subMenu>
</Menu>
<Menu type='Lighting & Studio Equipment'>
<subMenu>Background Material & Equip</subMenu>
<subMenu>Booms, Stands & Supports</subMenu>
<subMenu>Continuous Lighting</subMenu>
<subMenu>Light Controls & Modifiers</subMenu>
<subMenu>Light Meters</subMenu>
<subMenu>Portable Flash/Strobe</subMenu>
<subMenu>Props & Stage Equipment</subMenu>
<subMenu>Slaves</subMenu>
<subMenu>Studio Flash/Strobe</subMenu>
<subMenu>Other Lighting & Studio Items</subMenu>
</Menu>
<Menu type='Manuals, Guides & Books'>
<subMenu>How-To, Guides & Techniques</subMenu>
<subMenu>Camera Manuals</subMenu>
<subMenu>CheatSheets for Cameras</subMenu>
<subMenu>Lens Manuals</subMenu>
<subMenu>Other Manuals, Guides & Books</subMenu>
</Menu>
<Menu type='Photo Albums & Archive Items'>
<subMenu>Archival & Mounting Materials</subMenu>
<subMenu>Photo Albums</subMenu>
<subMenu>Other Albums & Archive Items</subMenu>
</Menu>
<Menu type='Printers, Scanners & Supplies'>
<subMenu>Photo Printers</subMenu>
<subMenu>Printing Software & Supplies</subMenu>
<subMenu>Scanners</subMenu>
</Menu>
<Menu type='Professional Video Equipment'>
<subMenu>Blank Tapes & Media</subMenu>
<subMenu>Cables & Wires</subMenu>
<subMenu>Cameras</subMenu>
<subMenu>Editing, Post-Production</subMenu>
<subMenu>Manuals</subMenu>
<subMenu>Monitors</subMenu>
<subMenu>Recorders & Players</subMenu>
<subMenu>Video Switchers, Routers</subMenu>
<subMenu>Other</subMenu>
</Menu>
<Menu type='Projection Equipment'>
<subMenu>Accessories</subMenu>
<subMenu>Projectors</subMenu>
<subMenu>Screens</subMenu>
<subMenu>Other Projection Equipment</subMenu>
</Menu>
<Menu type='Stock Photography & Footage'>
</Menu>
<Menu type='Tripods, Monopods'>
<subMenu>Accessories</subMenu>
<subMenu>Monopods</subMenu>
<subMenu>Tripods</subMenu>
<subMenu>Other Tripod, Monopod Items</subMenu>
</Menu>
<Menu type='Vintage'>
<subMenu>Accessories</subMenu>
<subMenu>Cameras</subMenu>
<subMenu>Projectors</subMenu>
<subMenu>Other Vintage Items</subMenu>
</Menu>
<Menu type='Wholesale Lots'>
<subMenu>Cameras</subMenu>
<subMenu>General Accessories</subMenu>
<subMenu>Vintage</subMenu>
<subMenu>Other</subMenu>
</Menu>
</CamerasAndPhotos>
</Commercila>";
[/PHP]
Please try to test my code and see the error
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joe Attardi |
last post by:
Hey all!
I was reading over at the IE Blog the other day
http://http://blogs.msdn.com/ie/] and read some interesting, and
encouraging news. According to Sunava Dutta, an IE Program Manager,...
|
by: namemattersnot |
last post by:
I have a SAJAX login authentication script that, if the the correct
password is provided, returns "history.go(0)" to the page and I then
use "eval()" on the returned data to refresh it.
If the...
|
by: mubarak basha |
last post by:
hi,
i wrote the following coding..........
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Getting...
|
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;
|
by: raknin |
last post by:
I'm using AJAX on my website, but internet explorer does not seem to actually be refreshing the data I retrieve via AJAX when I refresh the page. For example, I have a button that when pressed uses...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - Why is my AJAX page not updated properly when
using an HTTP GET request in Internet Explorer?...
|
by: zalek |
last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET",
url, false).
I noticed that in FireFox handler doesn't starts. It starts when I use
xmlHttp.open("GET", url,true).
I need to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |