The third argument in $.post
should be a function, but when you do this:
$.post("/preview", {content:userInput.val()}, callbackAfterLoad(data, ecBlock))
The third argument is not the function, but the return value of the function. Like this:
fn = callbackAfterLoad // function reference
fn = callbackAfterLoad() // function execution and return value reference
And when executed in your example, data
is not available yet. The correct syntax would be:
$.post("/preview", {content:userInput.val()}, callbackAfterLoad)
If you need to pass custom arguments to your callback, you can create a new proxy function like this:
var callback = function(data) {
callbackAfterLoad.call(this, data, ecBlock);
};
$.post("/preview", {content:userInput.val()}, callback);