jQuery success callback called with empty response when WCF method throws an Exception

前端 未结 5 1834
既然无缘
既然无缘 2021-02-05 11:55

I\'m tearing my hair out over this one, so bear with me (it\'s a long post).

Basic Info

  • ASP.NET 3.5 with WCF service in ASP.NET compatibility mode
5条回答
  •  不知归路
    2021-02-05 12:14

    I'm not familiar with ASP or WCF, but I am quite familiar with jQuery. The one thing that sticks out in my mind about your question is that your service is returning 202 Success when an exception is thrown. jQuery chooses which callback to call (success or error) based on the HTTP status code that is returned from the server. 202 is considered a successful response, and therefor jQuery will call success. If you want to have jQuery call the error callback, you need to make your service return a 40x or 50x status code. Consult http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for a list of HTTP status codes.

提交回复
热议问题