I am calling getValues function on document ready function.
jQuery(document).ready(function () {
getValues();
});
getValues function is given below.It is calling a getOffValue function.
var getValues= function() {
var html = '';
jQuery.ajax({
url: 'controller/function',
type: 'GET',
dataType: 'json',
success: function (data) {
jQuery.each(data, function (index, element) {
rate=getOffValue(element.off_id);
html += '<div class="col-md-3" style="padding:10px"><div class="row"></div></div>';
});
jQuery("#div").append(html);
},
error: function (data) {
alert("Error" + data);
}
});
}
getOffValue function is given below. need to return its result to calling function.
var getOffValue = function(id) {
var html = '';
return jQuery.ajax({
url: 'controller/function1',
type: 'POST',
dataType: 'json',
data: {off_id:id},
success: function (data) {
return data[0].rate;
},
error: function (data) {
alert("Error" + data);
}
});
}
I need to return the success result of getOffValue function to the function getOffValue. Need to get that value in rate variable.and need to append that value in html.but this code not working.showing the value as undefined.thanks in advance