-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jsonp #7
Comments
ic-ajax is a thin wrapper around An untested, coding inside GitHub's comment editor version follows: ic.ajax.raw(url, { dataType: 'jsonp', jsonpCallback: 'callbackName' }); Note that this will not play nicely with Ember's run loop by default. You'll need to do some more shenanigans to make that work. @fivetanley @rpflorence This issue can be closed. |
@nathanhammond What are these shenanigans? If I console log the the output in the first (resolve) callback on
How did you get around this in the run loop? |
Most of this is because the JSONP callback will be running in a global scope asynchronously. |
@nathanhammond Eeek that sounds like quite the hack. Could you post an On 13 July 2014 02:13, Nathan Hammond notifications@github.com wrote:
|
For example, in the callback: var object = App.__container.lookup('controller:login');
Ember.set(object, 'property', value); That should get you the Ember object that you need to set properties on, set it, and wrapped in a run loop it should all work out! WARNING: Code is untested, and written in the comment editor without checking method signatures. |
@nathanhammond Thanks for that. Did not quite get it working for me. Hope that ic-ajax fixes this, and provides a usable way to use jsonp. |
What about something like... var promise = new Ember.RSVP.Promise(function(resolve, reject){
ic.ajax.raw(url, { dataType: 'jsonp', jsonpCallback: 'callbackName' }).then(function(results){
Ember.run(null, resolve, results);
});
}); It should be noted that ic-ajax isn't really needed unless you want the fixture data stubbing. Since 1.3 ember-testing has been able to observe jQuery ajax requests and stop tests until they all finish. For all other promises, you shouldn't get errors if you upgrade to 1.6 you'll get test-friendly promises that are auto wrapped in the run loop: http://emberjs.com/blog/2014/07/07/ember-1-6-0-and-ember-1-7-0-beta-released.html In the mean time, I'm not sure that the library will be maintained to update it in the mean time. You usually should not have any problems upgrading ember as we follow semver. I don't work at instructure anymore and have started using Trek's pretender library for ajax stubbing in my day job. Don't have much time to work on this or have permission to merge pull requests anymore. |
I'm having trouble when hitting an endpoint that uses jsonp. (tumblr, in my case).
Same Origin is telling me though shall not pass, though.
This works
But this doesn't
The text was updated successfully, but these errors were encountered: