Created
July 11, 2013 13:42
-
-
Save knownasilya/5975538 to your computer and use it in GitHub Desktop.
RSVP with jQuery.ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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