[Seaside] Ajax and error management
Boris Popov, DeepCove Labs
boris at deepcovelabs.com
Mon May 16 22:32:36 UTC 2011
Thierry,
Complex functions like these are best implemented in JavaScript on your
file library, you can then generate a much simpler call using Seaside's
abstraction to that function.
Regards,
-Boris
-----Original Message-----
From: seaside-bounces at lists.squeakfoundation.org
[mailto:seaside-bounces at lists.squeakfoundation.org] On Behalf Of Thierry
Thelliez
Sent: 16 May 2011 18:25
To: Seaside - general discussion
Subject: Re: [Seaside] Ajax and error management
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-jqueryl
oad.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
_______________________________________________
seaside mailing list
seaside at lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
More information about the seaside
mailing list