I don’t understand very well how this JS function gets the data. This is the first variation of my code:
function iReceived(msg) {
console.log(msg.data);
};
var rest = $.ajax({
type: "POST",
dataType:'jsonp',
url: "https://api.novaposhta.ua/v2.0/json/",
data: {"modelName": "Address",
"calledMethod": "getCities",
"methodProperties":{},
"apiKey": "XXXXXXXXXXXXXXXXXXX"},
success: function(e) { iReceived(e) },
});
The function iReceived
prints the data that it gets. But in the second variation:
function iReceived(msg) {
console.log(msg.data);
};
var rest = $.ajax({
type: "POST",
dataType:'jsonp',
url: "https://api.novaposhta.ua/v2.0/json/",
data: {"modelName": "Address",
"calledMethod": "getCities",
"methodProperties":{},
"apiKey": "XXXXXXXXXXXXXXXXXXX"},
success: iReceived(e) ,
});
the function returns undefined
. Please, tell me why this variantion works a different way.