[Seaside] Ajax and error management

Thierry Thelliez thierry.thelliez.tech at gmail.com
Sun May 15 04:59:17 UTC 2011


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