Created
January 10, 2016 18:51
-
-
Save sebnozzi/402873647d5b8036729c to your computer and use it in GitHub Desktop.
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
val jsonStrToSend = "" | |
val serverUrl = "" | |
def handleAjaxError(jqXHR: JQueryXHR, textStatus: String, errorThrow: String): Unit = { | |
println("Error while performing AJAX POST") | |
} | |
def handleAjaxSuccess(data: js.Any, textStatus: String, jqXHR: JQueryXHR): Unit = { | |
val jsonFromServer = jqXHR.responseText | |
println(s"Got from server: $jsonFromServer") | |
} | |
val ajaxSettings = js.Dynamic.literal( | |
url = serverUrl, | |
contentType = "application/json", | |
data = """{"input": "hello"}""", | |
`type` = "POST", | |
success = handleAjaxSuccess _, | |
error = handleAjaxError _).asInstanceOf[org.scalajs.jquery.JQueryAjaxSettings] | |
jQuery.ajax(ajaxSettings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment