LiftRules.ajaxTimeoutFailure?

67 views
Skip to first unread message

Daniel Hobi

unread,
Sep 12, 2012, 4:22:28 AM9/12/12
to lif...@googlegroups.com
Hi Lifters!

We are currently in a situation where an ajax call could...
1. simply time out.
2. get a 500 from our server.

LiftRules.ajaxDefaultFailure does currently not distinguish between these two cases afaik.

Therefore I thought that something like this would be cool...

LiftRules.ajaxTimeoutFailure = Full(() => JsCmds.Alert("Sorry, but our server is slow as hell."))
LiftRules.ajaxDefaultFailure = Full(() => JsCmds.Alert("Opps, that shouldn't happened. Please contact our support."))

...or is there already a possibility to get that functionality?

Daniel


Daniel Hobi

unread,
Sep 13, 2012, 3:23:40 AM9/13/12
to lif...@googlegroups.com
Just for the sake of completeness...here is my solution:

//Provide own implementation of liftajax.js
LiftRules.renderAjaxScript = (session : LiftSession) => MyScriptRenderer.ajaxScript

//Add some LiftRules
MyLiftRules.ajaxTimeoutFailure = {
      Full(() => JsCmds.Alert("Timeout happened"))
}

MyLiftRules.ajaxSpecificFailure = List(
      (500, () => JsCmds.Alert("Error 500")),
      (404, () => JsCmds.Alert("Page not found"))
 )

See a working example on github: https://github.com/dhobi/liftajax

Daniel

David Pollak

unread,
Sep 13, 2012, 2:21:50 PM9/13/12
to lif...@googlegroups.com
Sure. Please open a ticket.

Perhaps we should also have some kind of setting to allow for long Ajax requests.




--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
 
 



--
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net


Daniel Hobi

unread,
Sep 14, 2012, 8:33:30 AM9/14/12
to lif...@googlegroups.com
Done #1320. (https://github.com/lift/framework/issues/1320)


>> Perhaps we should also have some kind of setting to allow for long Ajax requests.
Ahh that would be great and exactly hit our needs! I think that this one deserves its own ticket? :-)
Reply all
Reply to author
Forward
0 new messages