一番短いajaxライブラリ
「ajaxはもうスーパーサイヤ人と同じくらい普通(c)id:amachang」な時代のための簡単コピペライブラリ
function ajax(url,onload){ var x=null try{ x= new XMLHttpRequest; }catch(e){ try{ x= new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ x= new ActiveXObject("Microsoft.XMLHTTP"); }}; x.onreadystatechange=function(){ if(x.readyState==4) onload(x.responseText); } x.open("GET",url,true); x.send(""); } function ahah(url,id){ ajax(url,function(tx){ document.getElementById(id).innerHTML=tx; } ) } function ajson(url,onload){ ajax(url,function(tx){ var v=null; try{ eval("v="+tx); }catch(e){} onload(v); } ); }
XMLとか普通使わないよね! あとXMLHttpRequest使えない環境とか、もうこの世にはないさ! みんな幸せ!
(すいません、少し修正しました… 12:19)