传递给saltarelle' jquery ajax回调的参数的数据类型是什么?
本文关键字:回调 参数 数据类型 是什么 ajax jquery saltarelle | 更新日期: 2023-09-27 17:51:08
var jqopt = new jQueryAjaxOptions
{
Url = Model.Helper.ServiceEndpoint,
Type = "Get"
};
var req = jQuery.Ajax(jqopt);
req.Success(_ => { Log("Ajax succeeded: " + _.ToString()); });
req.Fail(_ => { Log("Calling back after failure!!" + _.ToString()); });
我需要看到错误信息而不是错误
下面是成功回调和错误回调的签名
private void jsSuccessCallBack(object data, string textStatus, jQueryXmlHttpRequest request)
{
var items = data as List<FamilyTrustBE>;
foreach (FamilyTrustBE item in items)
{
Helper.Log(string.Format("Result is: id {0}, {1}: {2}", item.id, item.name, item.description));
}
}
private void jsErrorCallBack(jQueryXmlHttpRequest request, string textStatus, Exception error)
{
dynamic myerr = error;
Helper.Log(string.Format("status={0} in ERROR callback. Error: {1}, Inner: {2}", textStatus, myerr.message, myerr.InnerException));
}
这是我的Helper.Log方法:
[IgnoreNamespace]
internal class Helper
{
public static void Log(string str)
{
var content = jQuery.Select(Helper.HTMLMessageDivSelector).GetHtml();
var messageDiv = jQuery.Select(Helper.HTMLMessageDivSelector);
messageDiv.Html(str + "<br/>" + content);
//write message to debug console if it is defined
dynamic w = System.Html.Window.Self;
{
if (w.console is object)
w.console.log(str);
}
}
}