Created
March 25, 2014 06:19
-
-
Save mattparlane/9756121 to your computer and use it in GitHub Desktop.
done() handler not firing for DELETE request when Content-Type header is set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
get '/' do | |
' | |
<script src=//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js></script> | |
<script> | |
$(function() { | |
$("a").click(function() { | |
var url = $(this).data("url"); | |
$.ajax({ | |
type: "delete", | |
url: url, | |
}) | |
.done(function() { | |
console.log("win"); | |
}) | |
.fail(function() { | |
console.log("fail"); | |
}); | |
return false; | |
}); | |
}); | |
</script> | |
<body> | |
<a href=# data-url="/fail">fail</a> | |
<a href=# data-url="/win">win</a> | |
</body> | |
' | |
end | |
delete '/fail' do | |
[200, {'Content-Type' => 'application/json'}, ''] | |
end | |
delete '/win' do | |
# either of these work: | |
[204, {'Content-Type' => 'application/json'}, ''] | |
[200, {}, ''] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment