I have a java script function to get some data from database.
function getSummary() {
var entries;
var totalRowCount;
$.ajax({
type: "GET",
url: "myurl",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data, status, jqXHR) {
entries= data;
// some logic here
for(var key in data) {
if(data.hasOwnProperty(key)) {
totalRowCount = data[key];
break;
}
}
},
error: function (jqXHR, status) {
alert('');
}
});
return(totalRowCount);
};
When i access the return value from above function in jsp page(var x=getSummary();) ,it says variable undefined.Can some one help me to fix the code?