我不确定这是否可能。我想像这样传递一个函数名作为参数
loadContent("http://test.com/", specialFunction);
specialFucntion
只是一个字符串:
function loadContent(href, functionIWant){
$.ajax({
type: "GET",
url: href,
dataType: "json",
success: function(res, textStatus, xhr) {
helper();
functionIWant + "()"; //So this would be treated as function
//and it actually calls specialFunction()
//is it possible for this?
}
});
}
我如何实现这一目标?
添加在
比方说,我会传入一个函数名数组,我该如何调用它?
for(var i = 0; i < functionIWant.length; i++){
functionIWant[i]; // how? appeciate a lot :)
}