jQuery AJAX call to Web API returns Status 240 when the API Controller Action returns BadRequest()

683 Views Asked by At

We have a Web API that has an action that returns BadRequest() which is a 400.

the call to the API looks like this:

$.post("/api/controller/action", {test:"Bad data"}).success(function(data){

    console.log(data)

});

the API Controller Action method returns an IHTTPActionResult of BadRequest("Invalid data recieved"); The Chrome inspector verifies the return was a 400, Fiddler verifys 400, but jQuery runs its success method and console.log(data); shows us that data.status = 240.

I do not think its just jQuery, because AngularJS's $http service does the exact same thing.

1

There are 1 best solutions below

0
On

I got this fixed by removing all suspicious extensions from both Chrome and Firefox. I realized i had Trovi installed, which is a virus causing some redirections (apparently). So turned out to be 3rd party software fiddling with my browsers.

Follow this link to clean your PC: http://www.anvisoft.com/resources/how-to-remove-trovi-com-browser-hijacker-trovi-com-removal-guide/

Same Postman call as before now correctly shows me 400 Bad Request instead of 240.