I am working with jQuery. I have a scenario where I have one callback method/function that is being called by two different functions/methods.
Problem: how can I know in my callback method/function that which of the two functions / methods called my callback method / function? Because I have some variables that I want assign some values depending upon which method/function called the callback.
Sample code:
var One = "";
var Two = "";
function first(){
var urlink = "https://192.168.150.3/api1?jsonpCallback=myCallback";
$.ajax({
type: "GET",
url: urlink,
dataType:"jsonp",
async: false,
});
}
function second(){
var urlink = "https://192.168.150.3/api2?jsonpCallback=myCallback";
$.ajax({
type: "GET",
url: urlink,
dataType:"jsonp",
async: false,
});
}
myCallback = function(data){
/* if the caller is first then
alert('first') & set value of var One;
else alert("second") & set value of var Two;
How to do this?*/
}
As far as I have read here and there, there is no solution and it didn't work for me atleast. Any suggestions/work around will be appreciated. :)