Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/main/scala/org/scalajs/dom/ext/Extensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ case class AjaxException(xhr: dom.XMLHttpRequest) extends Exception {
}

/**
* Wraps an XMLHttpRequest to provide an easy one-line way of making
* Wraps an XMLHttpRequest to provide an easy one-line way of making
* an Ajax call, returning a Future.
*/
object Ajax {
Expand Down Expand Up @@ -273,7 +273,7 @@ object Ajax {
}

def get(url: String,
data: InputData = "",
data: InputData = null,
timeout: Int = 0,
headers: Map[String, String] = Map.empty,
withCredentials: Boolean = false,
Expand All @@ -282,7 +282,7 @@ object Ajax {
}

def post(url: String,
data: InputData = "",
data: InputData = null,
timeout: Int = 0,
headers: Map[String, String] = Map.empty,
withCredentials: Boolean = false,
Expand All @@ -291,7 +291,7 @@ object Ajax {
}

def put(url: String,
data: InputData = "",
data: InputData = null,
timeout: Int = 0,
headers: Map[String, String] = Map.empty,
withCredentials: Boolean = false,
Expand All @@ -300,7 +300,7 @@ object Ajax {
}

def delete(url: String,
data: InputData = "",
data: InputData = null,
timeout: Int = 0,
headers: Map[String, String] = Map.empty,
withCredentials: Boolean = false,
Expand All @@ -313,7 +313,7 @@ object Ajax {
data: InputData,
timeout: Int,
headers: Map[String, String],
withCredentials: Boolean,
withCredentials: Boolean,
responseType: String): Future[dom.XMLHttpRequest] = {
val req = new dom.XMLHttpRequest()
val promise = Promise[dom.XMLHttpRequest]()
Expand All @@ -331,7 +331,10 @@ object Ajax {
req.timeout = timeout
req.withCredentials = withCredentials
headers.foreach(x => req.setRequestHeader(x._1, x._2))
req.send(data)
if (data == null)
req.send()
else
req.send(data)
promise.future
}
}
Expand Down