Why can’t I assign ajaxResult to result? console.log(result); works correctly which is inside the success option and appears second in the console. but result of the last of console.log(result); is undefined and first appears in the console. what is wrong with this?
$(function () {
var result;
$.ajax({
type: 'POST',
url: 'GelinlikSet',
dataType: 'json',
success: function (ajaxResult) {
result = ajaxResult;
console.log(result);
}
});
console.log(result);
});