Here you can change your function so that it can receive a callback.
function loadProjects(pID, callback) { $.ajax({ url: myURL, success: function (dataJS) { if ($.isFunction(callback)) { callback.call(); } } }); }
You can use it here.
function myCoolCallback() { alert("I am cool"); } loadProjects(123, myCoolCallback);
Or you can use it with an anonymous function.
loadProjects(123, function() { alert("I am cool"); });
jessegavin
source share