srilakshmisivala-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Nov-16 15:31 UTC
Ajax.PeriodicalUpdater
Hi ,
I''m tring to implement non-event based Ajax calls (GUI screen needs to
be updated periodically .
Work environment is :Grails framework + prototype
Following is the code that I implemented in the gsp:(Grails Server
pages)
Step 1:<body onload = "new
Ajax.PeriodicalUpdater(''time'', ''/
addnewproduct/addnewproduct/time'', { method:
''post'',frequency:
1,asynchronous:true,decay: 1,evalScripts:true});">
Step 2 :<div id="time">Time to be displayed here</div>
Step3:Step 3:def time = {
log.info('' current time is .....'')
render "${new Date()}" }
But I couldn''t get the periodocalUpdater working
Please help
ManyThanks
Srilakshmi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
I have a php script that pulls data from my db and generates a bunch of xml. I need a way to easily parse through the xml and pull different chunks out into different divs on my page. I''ve used Ajax.PeriodicalUpdater to pull in the entire contents, but i''m not too sure how to go about just selecting the data I want and inserting it into different divs. Any ideas? Thanks so much! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ajax.PeriodicalUpdater is probably not the best solution for that problem. If the XML has to be parsed client-side, you will probably want to use Ajax.Request and wrap it with PeriodicalExecuter. (http://prototypejs.org/api/periodicalExecuter) Thomas Woodham Data Editor - The Greenville News 864.298.4302 [BECAUSE THE NEWS NEVER STOPS] -----Original Message----- From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs@googlegroups.com] On Behalf Of polomasta Sent: Monday, December 03, 2007 10:13 AM To: Ruby on Rails: Spinoffs Subject: [Rails-spinoffs] Ajax.PeriodicalUpdater I have a php script that pulls data from my db and generates a bunch of xml. I need a way to easily parse through the xml and pull different chunks out into different divs on my page. I''ve used Ajax.PeriodicalUpdater to pull in the entire contents, but i''m not too sure how to go about just selecting the data I want and inserting it into different divs. Any ideas? Thanks so much! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
As I read more I noticed this too, so I''ve switched to Ajax.Request .
However, it keeps failing. Here are some more details as to my
project.
I am creating a windows sidebar gadget that needs to connect to a page
on a remote server that uses php to generate XML content. I then need
to parse through that content to find a specific xml tag, then iterate
through the child elements of that tag, extracting the content from
each child node and place it in a separate div for each child.
My ajax request keeps failing, and I am guessing this is because the
url i''m requesting is on a remote server (while the gadget is more or
less a local html page). Any ideas on how to work around this and then
perform the rest of what is needed? Below is my code thus far..
function init()
{
var url = ''http://www.myurl.com/xmlneeded.php'';
var ajax = new Ajax.Request(url, {
method: ''get'',
onSuccess: updateDisplay,
onFailure: alert("FAILED")})
}
var updateDisplay = function(transport) {
var xmlResponse = transport.responseText;
//now i need to find <myParent> in the XML and iterate through
the child nodes to extract info
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
> var url = ''http://www.myurl.com/xmlneeded.php''; > var ajax = new Ajax.Request(url, {The url would violate cross-site scripting limitations built into the XMLHttpRequest object. Any ajax request has to be on the same domain as the page making the request. Thomas Woodham Data Editor - The Greenville News 864.298.4302 [BECAUSE THE NEWS NEVER STOPS] -----Original Message----- From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs@googlegroups.com] On Behalf Of polomasta Sent: Monday, December 03, 2007 11:49 AM To: Ruby on Rails: Spinoffs Subject: [Rails-spinoffs] Re: Ajax.PeriodicalUpdater As I read more I noticed this too, so I''ve switched to Ajax.Request . However, it keeps failing. Here are some more details as to my project. I am creating a windows sidebar gadget that needs to connect to a page on a remote server that uses php to generate XML content. I then need to parse through that content to find a specific xml tag, then iterate through the child elements of that tag, extracting the content from each child node and place it in a separate div for each child. My ajax request keeps failing, and I am guessing this is because the url i''m requesting is on a remote server (while the gadget is more or less a local html page). Any ideas on how to work around this and then perform the rest of what is needed? Below is my code thus far.. function init() { var url = ''http://www.myurl.com/xmlneeded.php''; var ajax = new Ajax.Request(url, { method: ''get'', onSuccess: updateDisplay, onFailure: alert("FAILED")}) } var updateDisplay = function(transport) { var xmlResponse = transport.responseText; //now i need to find <myParent> in the XML and iterate through the child nodes to extract info } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
this is from the basic example on protoype website (http://
www.prototypejs.org/api/ajax/request)
var url = ''/proxy?url='' +
encodeURIComponent(''http://www.google.com/
search?q=Prototype'');
// notice the use of a proxy to circumvent the Same Origin Policy.
So I am guessing there is some way to make it worth with the gadget...
just not sure how.
as a side note... when I upload everything to my server and test it,
it runs fine if my url is a .xml file. If i try to reference the .php
that generates xml output... my response.Text is blank
On Dec 3, 11:07 am, "Woodham, Thomas"
<twood...-lm4C025e6zTdToeN5bPUx9BPR1lH4CV8@public.gmane.org>
wrote:> > var url = ''http://www.myurl.com/xmlneeded.php'';
> > var ajax = new Ajax.Request(url, {
>
> The url would violate cross-site scripting limitations built into the
XMLHttpRequest object. Any ajax request has to be on the same domain as the
page making the request.
>
> Thomas Woodham
> Data Editor - The Greenville News
> 864.298.4302
>
> [BECAUSE THE NEWS NEVER STOPS]
>
> -----Original Message-----
> From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf
Of polomasta
> Sent: Monday, December 03, 2007 11:49 AM
> To: Ruby on Rails: Spinoffs
> Subject: [Rails-spinoffs] Re: Ajax.PeriodicalUpdater
>
> As I read more I noticed this too, so I''ve switched to
Ajax.Request .
> However, it keeps failing. Here are some more details as to my project.
>
> I am creating a windows sidebar gadget that needs to connect to a page on a
remote server that uses php to generate XML content. I then need to parse
through that content to find a specific xml tag, then iterate through the child
elements of that tag, extracting the content from each child node and place it
in a separate div for each child.
>
> My ajax request keeps failing, and I am guessing this is because the url
i''m requesting is on a remote server (while the gadget is more or less
a local html page). Any ideas on how to work around this and then perform the
rest of what is needed? Below is my code thus far..
>
> function init()
> {
>
> var url = ''http://www.myurl.com/xmlneeded.php'';
> var ajax = new Ajax.Request(url, {
> method: ''get'',
> onSuccess: updateDisplay,
> onFailure: alert("FAILED")})
> }
>
> var updateDisplay = function(transport) {
> var xmlResponse = transport.responseText;
> //now i need to find <myParent> in the XML and iterate through
the child nodes to extract info }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Notice that their example has ''/proxy?url='' in front of the
url they are requesting. That''s how they''re getting around the
cross-site limitation. The proxy would be an accessible page on their web
server.
Thomas Woodham
Data Editor - The Greenville News
864.298.4302
[BECAUSE THE NEWS NEVER STOPS]
-----Original Message-----
From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-spinoffs@googlegroups.com] On Behalf Of polomasta
Sent: Monday, December 03, 2007 12:24 PM
To: Ruby on Rails: Spinoffs
Subject: [Rails-spinoffs] Re: Ajax.PeriodicalUpdater
this is from the basic example on protoype website (http://
www.prototypejs.org/api/ajax/request)
var url = ''/proxy?url='' +
encodeURIComponent(''http://www.google.com/
search?q=Prototype'');
// notice the use of a proxy to circumvent the Same Origin Policy.
So I am guessing there is some way to make it worth with the gadget...
just not sure how.
as a side note... when I upload everything to my server and test it, it runs
fine if my url is a .xml file. If i try to reference the .php that generates xml
output... my response.Text is blank
On Dec 3, 11:07 am, "Woodham, Thomas"
<twood...-lm4C025e6zTdToeN5bPUx9BPR1lH4CV8@public.gmane.org>
wrote:> > var url = ''http://www.myurl.com/xmlneeded.php'';
> > var ajax = new Ajax.Request(url, {
>
> The url would violate cross-site scripting limitations built into the
XMLHttpRequest object. Any ajax request has to be on the same domain as the
page making the request.
>
> Thomas Woodham
> Data Editor - The Greenville News
> 864.298.4302
>
> [BECAUSE THE NEWS NEVER STOPS]
>
> -----Original Message-----
> From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On
Behalf Of polomasta
> Sent: Monday, December 03, 2007 11:49 AM
> To: Ruby on Rails: Spinoffs
> Subject: [Rails-spinoffs] Re: Ajax.PeriodicalUpdater
>
> As I read more I noticed this too, so I''ve switched to
Ajax.Request .
> However, it keeps failing. Here are some more details as to my project.
>
> I am creating a windows sidebar gadget that needs to connect to a page on a
remote server that uses php to generate XML content. I then need to parse
through that content to find a specific xml tag, then iterate through the child
elements of that tag, extracting the content from each child node and place it
in a separate div for each child.
>
> My ajax request keeps failing, and I am guessing this is because the url
i''m requesting is on a remote server (while the gadget is more or less
a local html page). Any ideas on how to work around this and then perform the
rest of what is needed? Below is my code thus far..
>
> function init()
> {
>
> var url = ''http://www.myurl.com/xmlneeded.php'';
> var ajax = new Ajax.Request(url, {
> method: ''get'',
> onSuccess: updateDisplay,
> onFailure: alert("FAILED")})
> }
>
> var updateDisplay = function(transport) {
> var xmlResponse = transport.responseText;
> //now i need to find <myParent> in the XML and iterate through
> the child nodes to extract info }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---