Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
[split topic] - responseText vs responseXML
Old 09-02-2008, 11:02 AM [split topic] - responseText vs responseXML
Junior Talker

Posts: 1
Name: Ashwini
Trades: 0
Hi,
I am writing you with reference to your online post. I tried to implement the same in my code but getting http.responsetext has no properties error.I will be greatful if you can help me to sort the same out.
Here is the code i am using to generate the xml response.

if($sInfo == '') {
if($oResult = mysql_query($sQuery) and mysql_num_rows($oResult) > 0) {
$aValues = mysql_fetch_array($oResult,MYSQL_ASSOC);

//"header("Content-Type: text/xml; charset=utf-8")";
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><root>";
$xml.= "<itemdetails>";
$xml.= '<partno>'.$aValues['partno']. '</partno>';
$xml.= '<serialno>'.$aValues['serialno']. '</serialno>';
$xml.= '<landing_price>'.$aValues['landing_price']. '</landing_price>';
$xml.= '<purchase_date>'.$aValues['purchase_date']. '</purchase_date>';
$xml.= "</itemdetails>";
$xml.= "</root>";
print_r($xml);
}
}
Here is the code i am using to receive the values from the xml.
i am checking the response header as 'text/xml'.

if(http.status==200) {
alert(http.getAllResponseHeaders());

// var item_code=document.getElementById("ampleno").value ;;
var xmldoc = http.responseText;
alert(xmldoc);
//var message_nodes = http.responseText.getElementsByTagName("itemdetail s");
//var n_messages = message_nodes.length;
itemdetails = xmldoc.responseXML;

var partno = itemdetails.getElementsByTagName('partno').firstCh ild.data;
alert('partno ' + partno);


Please help me. I will appreciate it.
Hope to receive your response immediately.
Thanks in advance.

With regards
Ashwini

Viju2008 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-02-2008, 12:28 PM Re: [split topic] - responseText vs responseXML
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,522
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
[split from old thread -> http://www.webmaster-talk.com/javasc...sponsexml.html ]
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-02-2008, 12:34 PM Re: [split topic] - responseText vs responseXML
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,522
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
do NOT use responseText IF the return values are going to be XML code. (as your code is).

responseText does NOT process the "<?" declaration so use responseXML instead.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-02-2008, 12:37 PM Re: [split topic] - responseText vs responseXML
nyef's Avatar
Ultra Talker

Posts: 265
Name: Lucas
Trades: 0
responsetext is just a string, it has no properties

You can't use DOM methods on responsetext because it is nothing but a string.

In the code you gave you are using the method getElementsByTagName(). This is a DOM method, you can't use it on a string, even if the string contains html.
__________________
~nyef

Please login or register to view this content. Registration is FREE
nyef is offline
Reply With Quote
View Public Profile Visit nyef's homepage!
 
Reply     « Reply to [split topic] - responseText vs responseXML
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49400 seconds with 12 queries