开发者

PHP and Javascript Webservice

By using javascript am trying to cal a webservice.That service return response as follows..

<envelope>
<date_time>
Test', callbackTest  Wednesday, March 31, 2010 2:28:55 AM
</date_time>
</envelope>

I am using firefox as browser to execute the application.Thats why after creating the object of XMLHttpRequest try to read as follows

_xmlDoc.responseXML.getElementsByTagName开发者_如何学Go('date_time')[0].firstChild.nodeValue;

But it is showing output like undefined.please help me to solve this problem.What is actual problem ?


Something has changed with Firefox 3.6.2 Before I upgraded

myRequest.responseXML.getElementsByTagName('car')

was returning a list of nodes, with 3.6.2, nothing. In my case the response starts with

<xml version="1" encoding="UTF-8" standalone="yes">

Turns out I had â in my data. It was wrapped in CDATA so I thought I was safe. I'm sure it was fine prior to 3.6.2.


I am not sure you can do a getElementsByTagName() on a response object. Can you try it on the firebug command line first (since you said you are using firefox)?


Does the response start with

<?xml version="1.0"?>

or somethig similar? That may cause problems. What do you get from .responseText?

Also, are you sure firstChild will get you the text node? have you tried nodeValue directly on _xmlDoc.responseXML.getElementsByTagName('date_time')[0]?


Store this output in one variable and try this,

 $var=service output,
 $date_time=$var->envelope->date_time;

now try getElementsByTagName on this $date_time variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜