我正在进行一个返回XML的ajax调用.需要根据用户所在站点内的页面部分来不同地处理此XML.因此,我想实现1个调用函数的ajax函数,并且具有可变的成功函数…我敢肯定它很简单,但我已经搜索了一段时间而无法弄明白…
function makeAjaxCall(variableSuccessFunction) {
$.ajax.... (ajax stuff goes here)...
success: variableSuccessFunction(xml)
}
function ViewOne(xml) {
//take the XML and update the dom as appropriate
}
function ViewTwo(xml) {
//take the XML and update the dom as appropriate
}
$(document).ready(function() {
//be able to call either one of these functions
makeAjaxCall(ViewOne);
makeAjaxCall(ViewTwo);
}
最佳答案
原文链接:https://www.f2er.com/jquery/428146.html