Callaback parameters (follow..)

22 views
Skip to first unread message

Salvatore

unread,
Feb 16, 2011, 10:28:04 AM2/16/11
to MochiKit
Sorry I have corrected my errors.
The problem now is that my field ctx.user.data is not modified...



function FormController(){
this.user = {
name: "ALBATOR",
valide: true,
data : "TEST"
}
}

FormController.prototype = {
fetchdata: function () {
this.user.data = "Loading...";
var d = loadJSONDoc("http://search.twitter.com/search?
q=artyprog");
var x = this;
var gotMetadata = function (ctx, meta) {
alert(ctx.user.name);
ctx.user.data = meta.results[0].text;
};
var metadataFetchFailed = function (err) {
alert("The metadata for MochiKit.Async could not be
fetched :(");
};
d.addCallback(gotMetadata, this);
d.addErrback(metadataFetchFailed);

},
save: function () {
alert(angular.toJson(this.user));
}
}

Fredrik Blomqvist

unread,
Feb 16, 2011, 4:30:11 PM2/16/11
to MochiKit
You're confusing loadJSONDoc with a JSONP/XSS call.
loadJSONDoc uses standard xmlhttprequest, thus your call to twitter
fails due to the same domain restrictions.
Currently MochiKit doesn't have a JSONP call. Could be added though,
this has been discussed before.
Something like this should work (using the same Deferred interface).
http://web.archive.org/web/20080608205055/trac.mochikit.com/wiki/loadJSONDocFAD

// Fredrik Blomqvist

Per Cederberg

unread,
Feb 16, 2011, 9:24:47 PM2/16/11
to Fredrik Blomqvist, MochiKit
Well, there is always MochiKit.Async.loadScript for cross-domain stuff...

See the callback code here for example:

https://github.com/mochi/mochikit/blob/master/packed/MochiKit/customize.html

/Per

> --
> You received this message because you are subscribed to the Google Groups "MochiKit" group.
> To post to this group, send email to moch...@googlegroups.com.
> To unsubscribe from this group, send email to mochikit+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
>

Salvatore

unread,
Feb 17, 2011, 2:19:10 PM2/17/11
to MochiKit
Thanks Fredrik

On 16 fév, 22:30, Fredrik Blomqvist <fblomqv...@gmail.com> wrote:
> You're confusing loadJSONDoc with a JSONP/XSS call.
> loadJSONDoc uses standard xmlhttprequest, thus your call to twitter
> fails due to the same domain restrictions.
> Currently MochiKit doesn't have a JSONP call. Could be added though,
> this has been discussed before.
> Something like this should work (using the same Deferred interface).http://web.archive.org/web/20080608205055/trac.mochikit.com/wiki/load...
> > }- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

Salvatore

unread,
Feb 17, 2011, 2:19:30 PM2/17/11
to MochiKit
Thanks Per

On 17 fév, 03:24, Per Cederberg <cederb...@gmail.com> wrote:
> Well, there is always MochiKit.Async.loadScript for cross-domain stuff...
>
> See the callback code here for example:
>
> https://github.com/mochi/mochikit/blob/master/packed/MochiKit/customi...
>
> /Per
>
> 16 feb 2011 kl. 22:30 skrev Fredrik Blomqvist <fblomqv...@gmail.com>:
>
>
>
> > You're confusing loadJSONDoc with a JSONP/XSS call.
> > loadJSONDoc uses standard xmlhttprequest, thus your call to twitter
> > fails due to the same domain restrictions.
> > Currently MochiKit doesn't have a JSONP call. Could be added though,
> > this has been discussed before.
> > Something like this should work (using the same Deferred interface).
> >http://web.archive.org/web/20080608205055/trac.mochikit.com/wiki/load...
> > For more options, visit this group athttp://groups.google.com/group/mochikit?hl=en.- Masquer le texte des messages précédents -
Reply all
Reply to author
Forward
0 new messages