尝试获取Ajax.post失败的原因(使用Scala.Js),但只获取类名:
Ajax.post(
url = "...",
data = "...",
headers = Map("Content-Type"->"application/json; charset=utf-8",
"Csrf-Token" -> "...")
).map(_.responseText).map(
content => content match {
case _ => ...
}
).onFailure {
case err => log.info(s"failure ${err.toString} ${err.getCause} ${err.getMessage}")
}
我明白了:
failure org.scalajs.dom.ext.AjaxException null null
有可能得到原因吗?谢谢
我不这么认为。因为AjaxException
不能用一个原因构建:
case class AjaxException(xhr: dom.XMLHttpRequest) extends Exception {
def isTimeout = xhr.status == 0 && xhr.readyState == 4
}