I have a function that is expecting a result from an ajax call and assign it to the variable to result is successfully assigned to the variable but my problem is that how can I extract it?
Here is my code, I tried using $.each
to variable but it is undefined
<script type="text/javascript">
$(function () {
var branches = GetBranches();
console.log(branches);
//$.each(branches.d, function (key, val) {
// console.log(val.BranchCode);
//})
function GetBranches() {
return $.ajax({
type: 'POST',
url: 'testWS.asmx/GetBranches',
contentType: 'application/json; charset=utf-8',
dataType: 'JSON'
});
}
});
</script>
Here is my screenshot for the console.log(branches)
I want to retrieve/extract data from the responseJSON. How can possibly do this?