# Getting the result in xml from ajax call

**URL:** <https://www.ruby-forum.com/t/getting-the-result-in-xml-from-ajax-call/87871>\
**Category:** Rails\
**Created:** [March 6, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/getting-the-result-in-xml-from-ajax-call/87871 "2007-03-06T16:14:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@senthil](https://www.ruby-forum.com/u/senthil)\
**Post date:** [March 6, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/getting-the-result-in-xml-from-ajax-call/87871/1 "2007-03-06T16:14:55Z")

</div>

hi all,  
I want to make a ajax call to rails to particular action which  
returns xml and i want to get that xml in java script function.can any  
one help me to do this???

regards,  
senthil

---

<div class="post-metadata">

**Author:** ![senthil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@senthil](https://www.ruby-forum.com/u/senthil)\
**Post date:** [March 6, 2007, 4:27pm UTC](https://www.ruby-forum.com/t/getting-the-result-in-xml-from-ajax-call/87871/2 "2007-03-06T16:27:28Z")

</div>

senthil wrote:

> hi all,  
> I want to make a ajax call to rails to particular action which  
> returns xml and i want to get that xml in java script function.can any  
> one help me to do this???
> 
> regards,  
> senthil

Which part do you need help with? Sending the results from Rails as XML?  
Reading/parsing the XML in JavaScript?

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![senthil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@senthil](https://www.ruby-forum.com/u/senthil)\
**Post date:** [March 6, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/getting-the-result-in-xml-from-ajax-call/87871/3 "2007-03-06T21:25:27Z")

</div>

senthil wrote:

> ```
> I want to make a ajax call to rails to particular action which
> 
> ```
> 
> returns xml and i want to get that xml in java script function.can any  
> one help me to do this???

Suppose your application.js has function foo().

I suspect this action handler does what you need:

render :update do |rjs|  
rjs.call :foo, my\_xml  
end

That’s all. The my\_xml contents will be escaped as a big JavaScript  
string, and ‘foo(’ & ‘)’ will be put around it. Then the whole string  
will go across the wire, and get evaluated as JavaScript. It will  
de-escape the string, find XML, and pass that to foo().

–  
Phlip  
[http://c2.com/cgi/wiki?ZeekLand](http://c2.com/cgi/wiki?ZeekLand) ← NOT a blog!!
