/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function ajax(url, fn, async) { var xmlhttp = new XMLHttpRequest(); if ( async ) { xmlhttp.onreadystatechange = function() { if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) { fn(xmlhttp); } } } xmlhttp.open("GET", url, async); xmlhttp.send(null); if ( !async ) { fn(xmlhttp); } }
Comments
