I have a function that looks like this. It works.
Problem
This function myFunction is called by many other functions and depending on which one it should do something different on success.
Question
How is this solved? Some kind of callback? or do I have to send an extra parameter for the function to know?
Code
function myfunction()
{
var value = "myvalue";
var post_url = "ajax.php";
$.post(
post_url,
{
value: value,
},
function(responseText){
var json = JSON.parse(responseText);
if(json.success)
{
console.log('success');
}
}
);
}
}