Register
FAQ
Calendar
Search
Today's Posts
Rules
Guidelines
SMS enable your application
via Clickatell’s fast, simple and reliable API's, built to integrate with any system.
Click here
to learn more.
Flash Website Builder
- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites.
Check Out Custom
Custom Logo Design
by LogoBee. Website Design and Free Logo Templates available.
CodingForums.com
>
:: Client side development
>
JavaScript programming
>
Ajax and Design
AJAX and getElementById
User Name
Remember Me?
Password
Before you post, read our:
Rules
&
Posting Guidelines
Thread Tools
Rate Thread
Enjoy an ad free experience by logging in. Not a member yet?
Register
.
05-14-2009, 12:01 AM
PM User
|
#
1
otnj2ee
Regular Coder
Join Date: Apr 2007
Posts: 174
Thanks: 17
Thanked 0 Times in 0 Posts
AJAX and getElementById
I called the AJAX and it
returns
:
"<root><option id=\"test\" value=\"abc\">XYZ</option></root>"
In the
front
end::
if((req.readyState == 4 ) && req.status == 200) {
var answer =req.responseXML ;
alert(answer.getElementById('test').getAttribute("value") ); //It never displayed anything
//But
alert(answer.getElementsByTagName("option")[0].getAttribute("value") );
//worked and displayed the: abc
}
--Why does getElementById not work?
Thanks
Scott
Last edited by otnj2ee; 05-14-2009 at
12:03 AM
..
otnj2ee
View Public Profile
Find More Posts by otnj2ee
05-14-2009, 01:47 PM
PM User
|
#
2
bdl
Regular Coder
Join Date: Apr 2007
Location: Camarillo, CA US
Posts: 590
Thanks: 4
Thanked 83 Times in 82 Posts
There is no "id" attribute defined in the XML DOM. It's not an HTML/XHTML document!
Google search : responseXML getElementById
w3schools XML DOM
bdl
View Public Profile
Find More Posts by bdl
05-14-2009, 06:05 PM
PM User
|
#
3
A1ien51
Senior Coder
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
If that is all that is returned, that is an invalid XML document.
Eric
__________________
Tech Author [Ajax In Action, JavaScript
: Visual Blueprint]
A1ien51
View Public Profile
Visit A1ien51's homepage!
Find More Posts by A1ien51
05-14-2009, 06:16 PM
PM User
|
#
4
otnj2ee
Regular Coder
Join Date: Apr 2007
Posts: 174
Thanks: 17
Thanked 0 Times in 0 Posts
Thanks for the response.
Another question regarding to the <!DOCTYPE...
When is the <!DOCTYPE required?
For the AJAX returned string which does not have the <!DOCTYPE, but following processing of it has no problem at all.
Thanks
Scott
otnj2ee
View Public Profile
Find More Posts by otnj2ee
05-14-2009, 07:08 PM
PM User
|
#
5
otnj2ee
Regular Coder
Join Date: Apr 2007
Posts: 174
Thanks: 17
Thanked 0 Times in 0 Posts
To discuss with
A1ien51
, yes, the server returned:
"<root><option id=\"test\" value=\"abc\">XYZ</option></root>"
Now use AJAX,
request.responseXML
to follow-up, it actually works:
var ret = request.responseXML;
var value= ret.getElementsByTagName("option")[0].getAttribute("value");
alert(value); //
This will display: "abc"
So it appears to me that the returned string is a valid XML string.
Thanks
Scott
otnj2ee
View Public Profile
Find More Posts by otnj2ee
Bookmarks
del.icio.us
StumbleUpon
Google
Digg
Jump To Top of Thread
«
Previous Thread
|
Next Thread
»
Thread Tools
Show Printable Version
Email this Page
Rate This Thread
Rate This Thread
:
5 : Excellent
4 : Good
3 : Average
2 : Bad
1 : Terrible
Posting Rules
You
may not
post new threads
You
may not
post replies
You
may not
post attachments
You
may not
edit your posts
BB code
is
On
Smilies
are
On
[IMG]
code is
On
HTML code is
Off
Forum Rules
Forum Jump
User Control Panel
Private Messages
Subscriptions
Who's Online
Search Forums
Forums Home
:: Client side development
JavaScript programming
DOM and JSON scripting
Ajax and Design
JavaScript frameworks
Post a JavaScript
HTML & CSS
XML
Flash & ActionScript
Adobe Flex
Graphics and Multimedia discussions
General web building
Site reviews
Building for mobile devices
:: Server side development
Apache configuration
Perl/ CGI
PHP
Post a PHP snippet
MySQL
Other Databases
Ruby & Ruby On Rails
ASP
ASP.NET
Java and JSP
Other server side languages/ issues
ColdFusion
Python
:: Computing & Sciences
Computer Programming
Computer/PC discussions
Geek News and Humour
Web Projects and Services Marketplace
Web Projects
Small projects (quick fixes and changes)
Medium projects (new script, new features, etc)
Large Projects (new web application, complex features etc)
Unknown sized projects (request quote)
Vacant job positions
Looking for work/ for hire
Project collaboration/ partnership
Paid work offers and requests (Now CLOSED)
Career, job, and business ideas or advice
Domains, Sites, and Designs for sale
Domains for sale
Websites for sale
Design templates and graphics for sale
:: Other forums
Forum feedback and announcements
All times are GMT +1. The time now is
08:10 AM
.
Advertisement
Log in to turn off these ads.
Web Hosting UK
|
Dedicated Server Hosting
|
Shareware Junction
|
Software Geek
|
Flash file uploader
|
Cloud Server
|
Web Hosting Australia
Home
-
Contact Us
-
Archives
-
Link to CF
-
Resources
-
Top
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.