一个愚蠢的问题。
我在我的许多按钮单击、文本更改、下拉值更改等中调用 $.ajax 函数。所以我想使这个函数参数化。下面是我试图使用的代码。
function ajaxCall(ajaxUrl, methodName) {
try {
$.ajax({
type: 'POST',
url: ajaxUrl,
success: methodName
},
dataType: "html"
});
}
catch (e) {
alert(e.message);
}
}
在此“methodName”应该是控件应该使用的方法的名称。或者简而言之,当我使用 时ajaxCall('test.aspx','testMethod')
,控制权应该转移到
function testMethod(xmlResponse){
alert ('Inside testMethod');
}