ASP.NET中MVC使用AJAX调用JsonResult方法并返回自定义(3)


<span>$<span>.<span>ajax<span>({<span>
    url<span>:<span> <span>"/Fuck/FuckJson"<span>,<span>
    data<span>:<span> <span>""<span>,<span>
    dataType<span>:<span> <span>"json"<span>,<span>
    type<span>:<span> <span>"POST"<span>,<span>
    contentType<span>:<span> <span>"application/json; charset=utf-8"<span>,<span>
    dataFilter<span>:<span> <span>function<span> <span>(<span>data<span>)<span> <span>{<span>
        <span>return<span> data<span>;<span>
    <span>},<span>
    success<span>:<span> <span>function<span> <span>(<span>data<span>)<span> <span>{<span>
        alert<span>(<span>data<span>);<span>
    <span>},<span>
    error<span>:<span> <span>function<span> <span>(<span>fuckedObject<span>)<span> <span>{<span>
        <span>try<span> <span>{<span>
            <span>var<span> json <span>=<span> $<span>.<span>parseJSON<span>(<span>fuckedObject<span>.<span>responseText<span>);<span>
            alert<span>(<span>json<span>.<span>errorMessage<span>);<span>
        <span>}<span> <span>catch<span>(<span>e<span>)<span> <span>{<span>
            alert<span>(<span>'something bad happened'<span>);<span>
        <span>}<span>
    <span>}<span>
<span>})</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

现在请求这个Action,会发现Response的状态已经是500了。并且返回了Json格式的错误信息。

ASP.NET中MVC使用AJAX调用JsonResult方法并返回自定义

ASP.NET中MVC使用AJAX调用JsonResult方法并返回自定义

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjzgdw.html