I'm trying to display the response back from an ajax call using jquery within a pop up. My problem is that I don't know how to correctly make use of the callback method, shown below.
Many thanks
var data = "my data to post";
.loadAjaxWindow(url, jr.dialog(data), true,
function(xhr, textStatus, errorThrown) {
// stuff
},
true, 'post', data);
The method looks like the following:
// Ajax Method
loadAjaxWindow: function (url, callback, async, errorCallback, cache, type, data) {
success: function (data, textStatus, xhr) {
callback(data);
},
}
I've tried the following although the alert is not show?
var myCallBack = function(obj) {
alert("");
};
.ajax.loadJson(url, myCallBack,
true,
function(xhr, textStatus, errorThrown) {
// stuff
},
true,
'post',
JSON.stringify(data)
);
callback here, is a function which is called when the success callback of ajax is called...
so as an example..
var callback=function(obj){
console.log(obj);
jr.dialog(obj) //jr ??
//do yourstuff with ajax returned data which is as obj here
};
loadAjaxWindow: function (url, callback, async, errorCallback, cache, type, data) {
success: function (data, textStatus, xhr) {
callback(data);
},
}
so this will log datas return by the ajax call if you check in your console.