[Seaside] Ajax and error management

Thierry Thelliez thierry.thelliez.tech at gmail.com
Mon May 16 22:24:52 UTC 2011


Boris,

For the methods of JQAjaxSetup " onComplete:, onError:, onSuccess:,
onXhr:   I am trying to access the arguments that are supposed to be
passed.

For now, the following code:

         onComplete:   ( JSFunction new arguments: (Array with:
'arg1' with: arg2 with: 'arg3');
                                     add: (JSStream new
                                                    nextPutAll: 'alert';
                                                    argument: '''Arg1
= '' + arg1';
                                                   yourself);

generates:

        "complete":function(arg1){alert("'Arg1 = ' + arg1")}

The double quotes are not wanted.  Looking at the code, the
javascript: and javascriptContentOn: are intercepting the strings and
automatically adding the quotes.

The goal is to implement something like what can be seen at:
http://fishdujour.typepad.com/blog/2009/05/handling-errors-using-jqueryload.html

>From the article:

     $('#results').load('test/' + $(this).attr('href') + ' #wrap', "",
function(responseText, textStatus, XMLHttpRequest) {
        switch (XMLHttpRequest.status) {
         case 200: break;
         case 404:
          $('#results').html('<p>Looks like the results have not been
uploaded to the server yet. Please check back later.</p>');
          break;
         default:
          $('#results').html('<p>' + XMLHttpRequest.status + ': ' +
XMLHttpRequest.statusText + '. Please contact the club and let them
know.</p>');
         break;
   }


So going back to Seaside, I do not know what to do after this line:

      onError:   ( JSFunction new arguments: (Array with:
'responseText' with: 'textStatus' with: 'XMLHttpRequest');
                                     +++ Code here to generate the
following function  +++


function(XMLHttpRequest, textStatus, exception) {

   switch (XMLHttpRequest.status) {
    case 200: break;
    case 404:
     $('#results').html('<p>Looks like the results have not been
uploaded to the server yet. Please check back later.</p>');
     break;
    default:
     $('#results').html('<p>' + XMLHttpRequest.status + ': ' +
XMLHttpRequest.statusText + '. Please contact the club and let them
know.</p>');
     break;


Or is there another way to do that?

Thanks,
Thierry


More information about the seaside mailing list