Skip to content

Instantly share code, notes, and snippets.

@mulya
Created February 1, 2020 10:01
Show Gist options
  • Save mulya/8bbce460702624d090b000ccde12577d to your computer and use it in GitHub Desktop.
Save mulya/8bbce460702624d090b000ccde12577d to your computer and use it in GitHub Desktop.
ScalaJS JQuery facade ajax usage
$.ajax(js.Dynamic.literal(
url = "https:/url.net/1234567",
method = "GET",
cache = false,
success = (arg1: js.Dynamic, arg2: String, arg3: JQueryXHR) => {
println(js.JSON.stringify(arg1))
val p = document.createElement("p")
val text = document.createTextNode(arg1.track.id.toString)
p.appendChild(text)
document.body.appendChild(p)
},
error = (jqXHR: JQueryXHR, textStatus: String, errorThrow: String) => {
println(s"jqXHR=$jqXHR,text=$textStatus,err=$errorThrow")
}
).asInstanceOf[JQueryAjaxSettings])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment