Forum: Rails Spinoffs (closed, excessive spam) Getting the values from the responseText

A9f69678db1b08389d8c5edbce37a709?d=identicon&s=25 seran128 (Guest)
on 2008-06-17 21:08
(Received via mailing list)
I have a PeriodicalUpdater that when ran calls a php page. this page
then returns three values
in a string something like active|102|56|johnDoe
How do I get these values from the response so I can run javascript
logic against them

new Ajax.PeriodicalUpdater("", "user.php", {
// initial number of seconds interval between calls
   frequency : 60,
   decay : 1.2,
   onComplete: function(results) {
   if (200 == results.status)
    {
      var rsp_str = results.responseText;
        var ids = rsp_str.split("|");
        if(ids[0] != "active")
        {
          alert('Got Here');
          var url = "messagePop.php?user=" + ids[1] + "&id=" + ids[2] +
"&name=" + ids[3];
          testwindow= window.open (url,
"mywindow","location=0,status=0,scrollbars=0,width=400,height=320");
          testwindow.moveTo(0,0);
        }

    }
    }

   });
0147e858c76509f264daca9a460afd7a?d=identicon&s=25 Dan Dorman (Guest)
on 2008-06-17 23:29
(Received via mailing list)
On Tue, Jun 17, 2008 at 1:07 PM, seran128 <jeff.webdeveloper@gmail.com>
wrote:
>
> I have a PeriodicalUpdater that when ran calls a php page. this page
> then returns three values
> in a string something like active|102|56|johnDoe
> How do I get these values from the response so I can run javascript
> logic against them

Well, you can't use onComplete with Ajax.PeriodicalUpdater. The docs
say that "the onComplete callback is hijacked to be used for update
management....". However, you _can_ use the onSuccess callback (in
which case, you don't need to check if response.status == 200--but
heck, with Prototype you don't really need to do that anyway).

The pertinent docs: http://prototypejs.org/api/ajax/periodicalUpdater
(check the section at the very bottom of the page, "Beware! Not a
specialization!"

Good luck!

:Dan
This topic is locked and can not be replied to.