I have a url that returns a callback (JSONP):
http://warrencountyny.gov/rp/section.php?r=text&pk=302.15-12-24&town=520500
What is the proper way to use esriRequest with JSONP?
I have:
esriRequest(url, { callbackParamName: 'callback' }).then(function (result) {
console.log(result);
}).otherwise(function (err) { console.log(err); });
This fails with an expected JSON error.
If I do:
esriRequest(url, { responseType:'jsonp', callbackParamName: 'callback' }).then(function (result) {
console.log(result);
}).otherwise(function (err) { console.log(err); });
It returns the data (result.data) as a string:
callback({
"file": "Glens Falls/Glens Falls_302.15.pdf",
"size": "372.72 kB"
});
If I do this inside, I can get the "file":
esriRequest(url, { responseType: 'jsonp', callbackParamName: 'callback' }).then(function (response) {
var jsonp = response.data;
var f = new Function('callback', jsonp);
f(function (json) {
console.log(json.file);
});}).otherwise(function (err) { console.log(err); });
Is this the right way to do this, or am I missing something? Any thoughts are appreciated.