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()} | 
116 characters:
function a(u,c){with(new XMLHttpRequest){open('GET',u);onreadystatechange=function(){3<readyState&&c(this)};send()}}
(Thanks to @fearphage for reminding me of with!)
What do you even pass as the "c" parameter, though?
The c stands for “callback”, so you pass in a function to get run (and passed the XMLHttpRequest object) when the request returns.
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
  
            
See also: https://gist.github.com/segdeha/1f6ef6c0195262c57074