我有这个jquery ajax插件:
${project.build.finalName}
问题是:我需要将函数传递给参数onsuccess和onerror
类似于以下内容
(function ($) {
$.fn.Ajax_Data = function (Controller, Action, Data, onsuccess, onerror) {
event.preventDefault();
var options = {};
options.url = "/" + Controller + "/" + Action;
options.type = "POST";
options.data = JSON.stringify(Data);
options.dataType = "json";
options.contentType = "application/json";
options.success = onsuccess;
options.error = onerror;
$.ajax(options);
};
})(jQuery);
答案 0 :(得分:0)
我被发现是一个很好的解决方案
以下
function onsuccess() { $('tr:eq(' + RowIndex + ')').remove(); };
function onerror() { alert('there is some thing wrong !!'); };
$(this).Ajax_Data("OnePageGrid", "Delete", { Id: CurrantID },
onsuccess(),
onerror());
答案 1 :(得分:0)
我还得到了另一个解决方案 它运作良好
$(this).Ajax_Data("OnePageGrid", "Delete", { Id: CurrantID },
{ onsuccess: document.getElementById("tblBlah").deleteRow(RowIndex) },
{ onerror: alert('there is some thing wrong !!') });