[GS/SS Beta] [Seaside] Ajax and error management

Johan Brichau johan at inceptive.be
Sun May 15 06:31:41 UTC 2011


Thierry,

An investigation of the JQDialog>>html: learns me that it's a convenience method for the onOpen callback. 
As such, if you want to pass on an onError function to the #load function, your example should be implemented along the following lines:

html div
    id: (html nextId);
    script: (html jQuery new dialog
              autoOpen: false;
		onOpen: (html jQuery ajax load html: myComponent; onError: (html javascript ....));
              title: 'Title';
              height: 180;
              width: 420;
              resizable: false;
              autoOpen: false;
              modal: true).


On 15 May 2011, at 06:59, Thierry Thelliez wrote:

> Thanks Johan for your answers.
> 
> I think that what I am looking for is a way to call from Seaside the
> Ajax error callback function.
> 
> The definition of a load call in JQuery is as follows:
> 
> .load( url, [ data ], [ complete(responseText, textStatus, XMLHttpRequest) ] )
>         url  A string containing the URL to which the request is sent.
>         data  A map or string that is sent to the server with the request.
>         complete(responseText, textStatus, XMLHttpRequest)  A
> callback function that is executed when the request completes.
> 
> 
> The following code in Seaside
> 
> html div
>     id: (html nextId);
>     script: (html jQuery new dialog
>               html: myComponent;
>               title: 'Title';
>               height: 180;
>               width: 420;
>               resizable: false;
>               autoOpen: false;
>               modal: true).
> 
> html anchor
>       url: '#';
>       onClick: (( html jQuery id: html lastId) dialog open );
>       with: 'Test'
> 
> 
> creates the following Jquery code:
> 
> <script type="text/javascript">/*<![CDATA[*/function
> onLoad(){$("#id1").dialog({"autoOpen":false,"open":function(){$("#id1").load("http://here/app",["_s=InQqr610owmLtmMN","_k=ZRkC14tzdCC76Rkw","2"].join("&"))},"title":"Title","height":180,"width":420,"resizable":false,"modal":true});/*]]>*/</script>
> 
> 
> What I would like is something managing the load function errors, as
> described in http://fishdujour.typepad.com/blog/2009/05/handling-errors-using-jqueryload.html
> 
> The example method at JQAllFunctionalTests >> renderTimeoutOn:
> provides a global error trapping, but not an error mechanism for a
> particular Ajax call (as far as I understand it).
> 
> 
> I would like to code something like:
> 
> html div
>     id: (html nextId);
>     script: (html jQuery new dialog
>               html: myComponent;
>               title: 'Title';
>               height: 180;
>               width: 420;
>               resizable: false;
>               autoOpen: false;
>               modal: true
>               complete: ( html javascript
> 			'function(response, status, xhr) {
>                                                      if (status ==
> "error") { alert('oh oh'); }).
> 
> 
> That would translate in something like:
> 
> <script type="text/javascript">/*<![CDATA[*/function
> onLoad(){$("#id1").dialog({"autoOpen":false,"open":function(){$("#id1").load("http://here/app",["_s=InQqr610owmLtmMN","_k=ZRkC14tzdCC76Rkw","2"].join("&"),function(response,
> status, xhr) { if (status == "error") { alert('oh oh');
> })},"title":"Title","height":180,"width":420,"resizable":false,"modal":true});/*]]>*/</script>
> 
> 
> Thierry



More information about the seaside mailing list