I want to call an action via an ajax call with the following code:
$.ajax({
url: Craft.getActionUrl(_this.options.updateRestockAction),
method: 'POST',
headers: headers,
data: data,
success: function(data) {
console.log(data);
},
error: function(jqXHR, textStatus) {
console.log('error');
},
complete: function(jqXHR, textStatus) {
console.log('complete');
}
});
My action is being called successfully. However, I can't find out how to return data to the success callback. Any idea how to do this? I'm using Craft 3.
Thanks
Response
in your controller?