473,385 Members | 1,356 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,385 software developers and data experts.

Basic Ajax question

I'm fairly new to Ajax - I understand the principles of XML, can do
the PHP side, but am getting a bit lost with the JavaScript.

I've seen a couple of different ways of using JS to manipulate the
XML: 1 way using the getElementsByTagName method (as advocated by
W3Schools - http://www.w3schools.com/Dom/dom_nodes_get.asp) and a
seemingly different method (http://scriptasylum.com/tutorials/
xml_javascript/xml_javascript.html) - is either way recommended more
or less (or any other way I haven't found yet)?

I also haven't found any kind of decent API - is there one about? For
example, I want to be able to get the value of an attribute from one
of my nodes - I tried

xmlDoc.getElementsByTagName("info")
[0].childNodes[0].getAttribute("type");

but it doesn't work (in either IE or Firefox), but I can't find any
other way to do it. Cross-browser compatibility is also a big concern
for me, so if anyone can point me in the direction of a decent
tutorial, I'd be most grateful!

Thanks,
Chris
Jul 20 '08 #1
3 1148
On Jul 20, 11:35 am, ChrisW <c.c.w...@gmail.comwrote:
I'm fairly new to Ajax - I understand the principles of XML, can do
the PHP side, but am getting a bit lost with the JavaScript.

I've seen a couple of different ways of using JS to manipulate the
XML: 1 way using the getElementsByTagName method (as advocated by
W3Schools -http://www.w3schools.com/Dom/dom_nodes_get.asp) and a
seemingly different method (http://scriptasylum.com/tutorials/
xml_javascript/xml_javascript.html) - is either way recommended more
or less (or any other way I haven't found yet)?

I also haven't found any kind of decent API - is there one about? For
example, I want to be able to get the value of an attribute from one
of my nodes - I tried

xmlDoc.getElementsByTagName("info")
[0].childNodes[0].getAttribute("type");

but it doesn't work (in either IE or Firefox), but I can't find any
other way to do it. Cross-browser compatibility is also a big concern
for me, so if anyone can point me in the direction of a decent
tutorial, I'd be most grateful!
Do you know about JSON? It is generally preferred over XML these days.
It is easier to extract data from the JSON when it has been converted
to a JavaScript object than it is to extract data out of an XML
document.

http://json.org/

Peter
Jul 21 '08 #2
On 21 Jul, 03:12, Peter Michaux <petermich...@gmail.comwrote:
On Jul 20, 11:35 am, ChrisW <c.c.w...@gmail.comwrote:
I'm fairly new to Ajax - I understand the principles of XML, can do
the PHP side, but am getting a bit lost with the JavaScript.
I've seen a couple of different ways of using JS to manipulate the
XML: 1 way using the getElementsByTagName method (as advocated by
W3Schools -http://www.w3schools.com/Dom/dom_nodes_get.asp) and a
seemingly different method (http://scriptasylum.com/tutorials/
xml_javascript/xml_javascript.html) - is either way recommended more
or less (or any other way I haven't found yet)?
I also haven't found any kind of decent API - is there one about? For
example, I want to be able to get the value of an attribute from one
of my nodes - I tried
xmlDoc.getElementsByTagName("info")
[0].childNodes[0].getAttribute("type");
but it doesn't work (in either IE or Firefox), but I can't find any
other way to do it. *Cross-browser compatibility is also a big concern
for me, so if anyone can point me in the direction of a decent
tutorial, I'd be most grateful!

Do you know about JSON? It is generally preferred over XML these days.
It is easier to extract data from the JSON when it has been converted
to a JavaScript object than it is to extract data out of an XML
document.

http://json.org/

Peter
Thanks for the link, though I still have a few questions.

Is XML becoming obsolete? A couple of modules I did at a large UK
university a couple of years ago seemed to promote XML as the ultimate
data-handling tool, and that the XML-based databases etc were the best
thing ever to have been invented.

There are still reasons why I'd like to understand the XML-based
methods - a lot of the ways of storing data in the scientific field I
work in uses XML (e.g. STMML, MathML, and also RSS)

I'm still worried about the issue of cross-browser compatibility - are
the JS methods for manipulating JSON data better suited for this than
the methods I found for XML, which only work in IE?

Thanks,
Chris
Jul 21 '08 #3
On Jul 21, 6:03 am, ChrisW <c.c.w...@gmail.comwrote:

[snip]
Is XML becoming obsolete?
No. Not at all.

Many folks are choosing to use JSON as their data transport format
rather than choosing XML.

A couple of modules I did at a large UK
university a couple of years ago seemed to promote XML as the ultimate
data-handling tool, and that the XML-based databases etc were the best
thing ever to have been invented.
Some interesting perspectives:

http://www.tbray.org/ongoing/When/20...03/16/XML-Prog
http://www.tbray.org/ongoing/When/20.../03/24/XMLisOK

There are still reasons why I'd like to understand the XML-based
methods - a lot of the ways of storing data in the scientific field I
work in uses XML (e.g. STMML, MathML, and also RSS)
If the systems already use XML then it is probably best to go with the
flow and use XML.

I'm still worried about the issue of cross-browser compatibility - are
the JS methods for manipulating JSON data better suited for this than
the methods I found for XML, which only work in IE?
Extracting data from a JSON text that has been converted to a
JavaScript object is much easier than extracting data from an XML
document.

Peter
Jul 21 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tarun.sinha | last post by:
Hello All Please Help me out, I have heard about Ajax Programming. I want to use it in my application but i can't understand the basic of Ajax.I serach a lot and studied in google Please...
4
by: Richard Carpenter | last post by:
Considering a typical scenario where the user is presented a list of customers and, upon selecting one and clicking a button, they are then presented with a new page depicting the orders for that...
4
by: Tami | last post by:
Hello, I could use some advice on the best way to connect to some php in my source code using ajax. So that the php will re-execute after so much time with a script elsewhere on the server. Please...
11
by: walterbyrd | last post by:
With PHP, libraries, apps, etc. to do basic CRUD are everywhere. Ajax and non-Ajax solutions abound. With Python, finding such library, or apps. seems to be much more difficult to find. I...
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm about to finally make the jump and start a new site using AJAX. THe question i have for all of you AJAX developers out there is which one? 1. The Standard AJAX frame work 2. The Tool kit....
4
by: JDeats | last post by:
Note, I am not trying to use the Microsoft AJAX Framework, yes I am aware of what it is and what it does.... The techniques refered to as "AJAX" predate this toolkit and ASP.NET 2.0 What I am...
7
by: MikeB | last post by:
Hello All, I am new to ajax and wanted to start by trying something simple. I have a web form with an updatepanel and then inside the update panel I have a listbox. Then outside of the updatepanel...
0
by: JJ | last post by:
New to AJAX: If I have the ajaxToolkit:ToolkitScriptManager on a page, do I still need to include the asp:scriptmanager if I am using an update panel for example? If I started building a site...
6
by: Jonathan Wood | last post by:
Greetings, I'd like to implement some AJAX features on an existing ASP.NET site. I have one example of doing this but, otherwise, don't know much about it. I have one question, though, about...
2
by: BobF | last post by:
<given> When starting a new AJAX Control enabled site, a set of files are created. These are created -without- a master page. </given> To add a master page, I've been adding the master via...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 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.