1👍
✅
var data = $.ajax({
dataType: "json",
url: "http:/127.0.0.1:8000/api/items/yeasts",
success: onSuccess,
error: onError,
context: self
});
var onSuccess = function(data){
alert("It worked!");
alert(data);
alert(self);
console.log(data);
// var this_data = data;
this.yeast_options = data;
return data;
}
setting context property of ajax call to your viewmodel. so it is accessible in the success method.
Source:stackexchange.com