Last Updated: February 25, 2016
·
954
· mattcodez

jQuery ajax doesn't always fire success on a 200

I just had an instance where a server request was clearly returning a response code of 200 but my jQuery success callback was never firing. Just experimenting around, I found that adding some output to the request on the server would cause the callback to fire. I was just doing a simple POST and didn't really need to return anything. Reading the documentation for $.POST, I realized I had incorrectly used the final parameter of dataType for my sending data, not receiving data. Removing this dataType parameter altogether allows the callback to be fired on a 200 even with no data being returned in the response body.