Last active
June 23, 2020 04:21
-
-
Save segdeha/5601610 to your computer and use it in GitHub Desktop.
Smallest possible Ajax implementation (120 characters)
This file contains hidden or 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
function a(u,c){var x=new XMLHttpRequest;x.open('GET',u);x.onreadystatechange=function(){3<x.readyState&&c(x)};x.send()} |
Using commas instead of semicolons means you can get away without the {}
, so you could shave off a couple more characters :p
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
c
stands for “callback”, so you pass in a function to get run (and passed theXMLHttpRequest
object) when the request returns.