I have following Ajax code for GET and DELETE use-cases in scalajs-react.
DELETE:
val ajax = Ajax("DELETE", "http://localhost:8081/delete/"+id)
.setRequestContentTypeJsonUtf8
.send("")
.onComplete { xhr =>
xhr.status match {
case 200 => {
println("Success")
....more code
)
}
case _ => {
println("Status is"+xhr.status)
Callback.log(xhr.responseText)
}
}
}
ajax.asCallback
...GET:
val ajax = Ajax("GET", "http://localhost:8081/fetch/"+id)
.setRequestContentTypeJson
.send("")
.onComplete { xhr =>
xhr.status match {
case 200 => {
println("Success")
....more code
}
case _ => {
println("Status is"+xhr.status)
Callback.log(xhr.responseText)
}
}
}
ajax.asCallback
While GET works as expected with code inside onComplete invoked on request completion, for DELETE this is not the case. For DELETE onComplete code is never invoked on request completion, even though on server side delete action is successful.
Why this difference in behaviour?