How to redirect/ignore failed Ajax remotetimer

View: New views
7 Messages — Rating Filter:   Alert me  

How to redirect/ignore failed Ajax remotetimer

by bondo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I have a statement like:
echo $ajax->remoteTimer(array('url'=>'refresh/10',
'update'=>'refresh_response', 'frequency'=>120));

If the client cannot reach the specified url (because the server is
down), is it possible to update a different div or do nothing at all?
I don't want to update the specified div if it couldn't actually grab
the data from the server.

Thx.
Bondo.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to redirect/ignore failed Ajax remotetimer

by schneimi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Do I correctly understand that if the url cannot be reached, the DIV
is updated with an error-page, and you want to avoid that? I thought
there would already happen nothing at all when it comes to a timeout.

Not sure, but maybe the 'failure' ajax option could help. Another try
could be to check the ajax-responseText of valid content, using the
'success' option.

Hope this helps.

On 8 Jul., 17:18, bondo <kevd...@...> wrote:

> I have a statement like:
> echo $ajax->remoteTimer(array('url'=>'refresh/10',
> 'update'=>'refresh_response', 'frequency'=>120));
>
> If the client cannot reach the specified url (because the server is
> down), is it possible to update a different div or do nothing at all?
> I don't want to update the specified div if it couldn't actually grab
> the data from the server.
>
> Thx.
> Bondo.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to redirect/ignore failed Ajax remotetimer

by bondo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


No, it replaces the div with nothing at all but that isn't exactly
what I want.

For example, I have a weather element that is updated every 30
minutes. If it can't retrieve the information from the web server, the
element is blank and the weather information that was there,
disappears. The next time it checks, 30 minutes later, it is able to
retrieve the data and the weather information returns.

What I want to have happen is that if it can't retrieve the
information for whatever reason, the div is not updated at all and
maybe some other div is updated. So in my example, the original
weather information would remain (although it would be an hour old)
until it could successfully update it with new information.

On Jul 8, 11:02 am, schneimi <michael.schne...@...> wrote:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to redirect/ignore failed Ajax remotetimer

by schneimi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ok now I understand. I am not sure, but I think there is no way but
checking the request-content.

The only way i found, is to not set the 'update'-option but instead
using the 'success'-option like this:

'success' => 'if (request.responseText != "") {$
("refresh_response").innerHTML = request.responseText}'

It's not really beautiful, but should be a good workaround.

Maybe someone else shows up with a nicer solution, your problem should
be a common problem.

On 8 Jul., 19:18, bondo <kevd...@...> wrote:

> No, it replaces the div with nothing at all but that isn't exactly
> what I want.
>
> For example, I have a weather element that is updated every 30
> minutes. If it can't retrieve the information from the web server, the
> element is blank and the weather information that was there,
> disappears. The next time it checks, 30 minutes later, it is able to
> retrieve the data and the weather information returns.
>
> What I want to have happen is that if it can't retrieve the
> information for whatever reason, the div is not updated at all and
> maybe some other div is updated. So in my example, the original
> weather information would remain (although it would be an hour old)
> until it could successfully update it with new information.
>
> On Jul 8, 11:02 am, schneimi <michael.schne...@...> wrote:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to redirect/ignore failed Ajax remotetimer

by schneimi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I forgot, if you want to update another DIV on empty content, this
could look like:

If you want to update the DIV with some remote content:
'success' => 'if (request.responseText != "") {$
("refresh_response").innerHTML = request.responseText;} else {'.$ajax-
>remoteFunction(array('url' => 'error_url', 'update' =>
'another_div')).'}'

If you want to just put in some text:
'success' => 'if (request.responseText != "") {$
("refresh_response").innerHTML = request.responseText;} else {$
("another_div").innerHTML = 'some text'}'


On 8 Jul., 20:29, schneimi <michael.schne...@...> wrote:

> Ok now I understand. I am not sure, but I think there is no way but
> checking the request-content.
>
> The only way i found, is to not set the 'update'-option but instead
> using the 'success'-option like this:
>
> 'success' => 'if (request.responseText != "") {$
> ("refresh_response").innerHTML = request.responseText}'
>
> It's not really beautiful, but should be a good workaround.
>
> Maybe someone else shows up with a nicer solution, your problem should
> be a common problem.
>
> On 8 Jul., 19:18, bondo <kevd...@...> wrote:
>
> > No, it replaces the div with nothing at all but that isn't exactly
> > what I want.
>
> > For example, I have a weather element that is updated every 30
> > minutes. If it can't retrieve the information from the web server, the
> > element is blank and the weather information that was there,
> > disappears. The next time it checks, 30 minutes later, it is able to
> > retrieve the data and the weather information returns.
>
> > What I want to have happen is that if it can't retrieve the
> > information for whatever reason, the div is not updated at all and
> > maybe some other div is updated. So in my example, the original
> > weather information would remain (although it would be an hour old)
> > until it could successfully update it with new information.
>
> > On Jul 8, 11:02 am, schneimi <michael.schne...@...> wrote:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to redirect/ignore failed Ajax remotetimer

by bondo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks for the help. I'll give that a try and see how it goes.

On Jul 8, 12:37 pm, schneimi <michael.schne...@...> wrote:

> I forgot, if you want to update another DIV on empty content, this
> could look like:
>
> If you want to update the DIV with some remote content:
> 'success' => 'if (request.responseText != "") {$
> ("refresh_response").innerHTML = request.responseText;} else {'.$ajax->remoteFunction(array('url' => 'error_url', 'update' =>
>
> 'another_div')).'}'
>
> If you want to just put in some text:
> 'success' => 'if (request.responseText != "") {$
> ("refresh_response").innerHTML = request.responseText;} else {$
> ("another_div").innerHTML = 'some text'}'
>
> On 8 Jul., 20:29, schneimi <michael.schne...@...> wrote:
>
> > Ok now I understand. I am not sure, but I think there is no way but
> > checking the request-content.
>
> > The only way i found, is to not set the 'update'-option but instead
> > using the 'success'-option like this:
>
> > 'success' => 'if (request.responseText != "") {$
> > ("refresh_response").innerHTML = request.responseText}'
>
> > It's not really beautiful, but should be a good workaround.
>
> > Maybe someone else shows up with a nicer solution, your problem should
> > be a common problem.
>
> > On 8 Jul., 19:18, bondo <kevd...@...> wrote:
>
> > > No, it replaces the div with nothing at all but that isn't exactly
> > > what I want.
>
> > > For example, I have a weather element that is updated every 30
> > > minutes. If it can't retrieve the information from the web server, the
> > > element is blank and the weather information that was there,
> > > disappears. The next time it checks, 30 minutes later, it is able to
> > > retrieve the data and the weather information returns.
>
> > > What I want to have happen is that if it can't retrieve the
> > > information for whatever reason, the div is not updated at all and
> > > maybe some other div is updated. So in my example, the original
> > > weather information would remain (although it would be an hour old)
> > > until it could successfully update it with new information.
>
> > > On Jul 8, 11:02 am, schneimi <michael.schne...@...> wrote:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to redirect/ignore failed Ajax remotetimer

by bondo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


That worked perfect. Thanks!

On Jul 8, 12:52 pm, bondo <kevd...@...> wrote:

> Thanks for the help. I'll give that a try and see how it goes.
>
> On Jul 8, 12:37 pm, schneimi <michael.schne...@...> wrote:
>
> > I forgot, if you want to update another DIV on empty content, this
> > could look like:
>
> > If you want to update the DIV with some remote content:
> > 'success' => 'if (request.responseText != "") {$
> > ("refresh_response").innerHTML = request.responseText;} else {'.$ajax->remoteFunction(array('url' => 'error_url', 'update' =>
>
> > 'another_div')).'}'
>
> > If you want to just put in some text:
> > 'success' => 'if (request.responseText != "") {$
> > ("refresh_response").innerHTML = request.responseText;} else {$
> > ("another_div").innerHTML = 'some text'}'
>
> > On 8 Jul., 20:29, schneimi <michael.schne...@...> wrote:
>
> > > Ok now I understand. I am not sure, but I think there is no way but
> > > checking the request-content.
>
> > > The only way i found, is to not set the 'update'-option but instead
> > > using the 'success'-option like this:
>
> > > 'success' => 'if (request.responseText != "") {$
> > > ("refresh_response").innerHTML = request.responseText}'
>
> > > It's not really beautiful, but should be a good workaround.
>
> > > Maybe someone else shows up with a nicer solution, your problem should
> > > be a common problem.
>
> > > On 8 Jul., 19:18, bondo <kevd...@...> wrote:
>
> > > > No, it replaces the div with nothing at all but that isn't exactly
> > > > what I want.
>
> > > > For example, I have a weather element that is updated every 30
> > > > minutes. If it can't retrieve the information from the web server, the
> > > > element is blank and the weather information that was there,
> > > > disappears. The next time it checks, 30 minutes later, it is able to
> > > > retrieve the data and the weather information returns.
>
> > > > What I want to have happen is that if it can't retrieve the
> > > > information for whatever reason, the div is not updated at all and
> > > > maybe some other div is updated. So in my example, the original
> > > > weather information would remain (although it would be an hour old)
> > > > until it could successfully update it with new information.
>
> > > > On Jul 8, 11:02 am, schneimi <michael.schne...@...> wrote:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@...
To unsubscribe from this group, send email to cake-php-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price