$.ajax
has dataFilter
callback, which passes return value to success
. Note dataFilter
must return JSON
, so below works:
dataFilter: function(resp){
return JSON.stringify(JSON.parse(resp).results);
}
Question
I am populating checklist using remote source. My problem is that the remote source returns
{count: n, results: {...}}
, and x-editable doesnt expect to have to look in response.results
to get the list.
I have tried the following, which does not solve:
$ages.editable({
type: 'checklist',
source: '/api/ages/',
sourceOptions: {
success: function(resp){
return resp.results;
}
}
})
Using console, I can see that .success
is being hit, but the behaviour on screen is the "loading" spinner keeps on spinning.
Solution
$.ajax
has dataFilter
callback, which passes return value to success
. Note dataFilter
must return JSON
, so below works:
dataFilter: function(resp){
return JSON.stringify(JSON.parse(resp).results);
}