I have a problem with my AjaxRequest() function. Here it is:
function AjaxRequest(url, method, data) {
var response;
$.ajax({
method: method.toUpperCase(),
url: url,
data: data,
dataType: 'json',
success: function(data, status, xhr) {
response = JSON.stringify(data);
},
error: function(xhr, status, error) {
response = JSON.stringify({ success: false, message: "AJAX Fout" });
}
});
return response;
}
I want to return
the jQuery AJAX response, but it doesn't work.
I tried to solve this problem with a callback function, but then I can't pass parameters to my function, what makes it completely useless.
Could someone help me or show me an alternative?