jquery - Call jsonp callback inside a TypeScript module (devextreme) -
i call jsonp callback typescript module of devextreme. following code not working. call weatherresponse
callback, it's inside typescript module.
module tellmeweather { export function home(params: { id: }) { return { locationvalue: ko.observable("new york"), locationresults:ko.observable("no results"), gosearch: function () { $.ajax({ url: 'http://api.openweathermap.org/data/2.5/weather?q=' + this.locationvalue() + ',it&callback=weatherresponse', datatype: 'jsonp', jsonp: 'weatherresponse', success: function () { } }); } , weatherresponse: function (locdata:any) { this.locationresults("location name:"+locdata.name); } }; } }
don't specify 'jsonp' parameter @ all. let jquery work out. ajax request following
$.ajax({ url: 'http://api.openweathermap.org/data/2.5/weather?q=' + this.locationvalue() + ',it&callback=?', datatype: 'jsonp' }).done(function(result) { // code here });
you can find working script on github https://github.com/nils-werner/owm-display/blob/master/js/loader.js
Comments
Post a Comment