jQuery AJAX Responses in ASP.NET MVC

前端 未结 4 778
借酒劲吻你
借酒劲吻你 2021-01-03 03:43

Not even sure if this is the right way to title the question. I know I\'m making my AJAX calls all wrong... here\'s what I\'m doing right now (I\'m using ASP.NET MVC backend

4条回答
  •  [愿得一人]
    2021-01-03 04:27

    I've blogged about this same situation. Maybe it will help you in your situation as well. It's basically about having a custom exception class and an exception action attribute that will return the error. So you're able to use the success and error options of the $.ajax call. Which is in my opinion the right way of doing it.

    $.ajax call does provide functionality to handle success as well as error responses. No need to always return a success with an error flag set that you have to check on the client.

提交回复
热议问题