[Seaside-dev] JQuery XHR methods

Johan Brichau johan at inceptive.be
Mon Jul 28 20:09:27 UTC 2014


Reading through the documentation, it seems we could easily make this jQuery deprecation transparant for Seaside users:

- onComplete option -> always callback
- onSuccess option -> done callback
- onError option -> fail callback

Since the return value of the existing methods on JQAjaxSetup was self already (i.e. the JQAjaxSetup subinstance), making this a transparant change is possible by converting it to add a corresponding function call decoration on the jQAjaxSetup instance, which returns self as well and allows to chain the messages in exactly the same way as they were done before.

So the implementation of onComplete would be

JQAjaxSetup>>onComplete: aJSObject
	self call: 'always' with: ajSObject asFunction

Although this is a good thing for continuity, it's probably a bad idea to keep the old method names and rather make everyone use onFail:, onDone: and onAlways: instead (not sure about the last one though...).

Thoughts?

Johan

On 18 Jul 2014, at 17:46, Esteban A. Maringolo <emaringolo at gmail.com> wrote:

> I was needing to handle an "error" callback for an xhr post, and found
> there is no #onError: handler in JQPost. Went to jQuery website I
> noticed most of the success/fail/complete methods in JQAjax hierarchy
> are deprecated.
> 
> Deprecation Notice
> The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callback
> methods introduced in jQuery 1.5 aredeprecated as of jQuery 1.8. To
> prepare your code for their eventual removal, use jqXHR.done(),
> jqXHR.fail(), and jqXHR.always() instead.
> 
> Is anybody updating JQuery wrapper for that? Or is there already a way
> to deal with the new "promise" style way of chaining callbacks?.
> 
> What I'm doing now is something like:
> ((html jQuery post callback: [] value: ()) call: 'done' with: ("js
> function")) call: 'fail' with: ("fail function")
> 
> Regards!
> 
> 
> Esteban A. Maringolo
> _______________________________________________
> seaside-dev mailing list
> seaside-dev at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev



More information about the seaside-dev mailing list