Discussion:
Callaback parameters (follow..)
Salvatore
2011-02-16 15:28:04 UTC
Permalink
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));
}
}
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to mochikit+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
Fredrik Blomqvist
2011-02-16 21:30:11 UTC
Permalink
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
Post by Salvatore
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));
    }
}
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to mochikit+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
Per Cederberg
2011-02-17 02:24:47 UTC
Permalink
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
Post by Fredrik Blomqvist
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
Post by Salvatore
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));
}
}
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to mochikit+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
Salvatore
2011-02-17 19:19:30 UTC
Permalink
Thanks Per
Post by Per Cederberg
Well, there is always MochiKit.Async.loadScript for cross-domain stuff...
https://github.com/mochi/mochikit/blob/master/packed/MochiKit/customi...
/Per
Post by Fredrik Blomqvist
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...
// Fredrik Blomqvist
Post by Salvatore
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));
    }
}
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
For more options, visit this group athttp://groups.google.com/group/mochikit?hl=en.- Masquer le texte des messages précédents -
- Afficher le texte des messages précédents -
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to mochikit+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
Salvatore
2011-02-17 19:19:10 UTC
Permalink
Thanks Fredrik
Post by Fredrik Blomqvist
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...
// Fredrik Blomqvist
Post by Salvatore
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));
    }
}- Masquer le texte des messages précédents -
- Afficher le texte des messages précédents -
--
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to mochikit+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.
Loading...