I have a filter function which makes a synchronous ajax call. The callback of the function returns a json object which is then passed to a variable of the filter function which is then returned as the filter result. An infinite loop of ajax calls are made ONLY when the dataType of the ajax call is set to 'json'. When returning a string, there is no infinite loop.
Why does this code, when placed inside a filter function, cause a recursive infinite loop?
var result;
that = this;
$.ajax({
url: '/url/',
async: false,
dataType: 'json',
type: 'get',
success: function (links) {
that.result = links;
}
});
return that.result;