Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Created July 11, 2013 13:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save knownasilya/5975538 to your computer and use it in GitHub Desktop.
Save knownasilya/5975538 to your computer and use it in GitHub Desktop.
RSVP with jQuery.ajax
return Ember.RSVP.Promise(function (resolve, reject) {
var hash = {
url: geocodeUrl + "/" + params.latlng,
dataType: "jsonp",
jsonp: "jsonp",
data: {
key: apiKey,
includeEntityTypes: "Address"
}
};
hash.success = function (data) {
var addressObj = data.resourceSets[0].resources[0].address,
address = addressObj.addressLine + ", " + addressObj.locality,
result = Ember.Object.create({ latlng: latlng, address: address });
Ember.run(null, resolve, result);
};
hash.error = function (error) {
var result = Ember.Object.create({ latlng: latlng, error: error });
Ember.run(null, reject, result);
};
Ember.$.ajax(hash);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment