Short Ajax Script

AJAX - it

I wanted to see how small you could make a fully functional AJAX script that worked cross-browser and degraded gracefully, so I went through an old custom AJAX script and made it as small as I possibly could. In the resulting AJAX scripts, the post version is 410 characters and the GET version is only 359 characters long. The scripts are fully functional and accept the following parameters: URL, DATA (in string form), and ELEMENT (to update).

The scripts could be a little smaller, but it would really kill readability.

“Get” AJAX Script

function a(l,d,u){
try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');}catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 && r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}
r.open('GET', l+'?'+d, true);r.send(d);
}
}

“Post” AJAX Script

function b(l,d,u){
try{r = new XMLHttpRequest();} catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');} catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 && r.status == 200){document.getElementById(u).innerHTML=r.responseText;}}
r.open('POST', l, true);r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');r.send(d);
}
}

Combined AJAX Script

This combined script also accepts a fourth parameter ‘p’ that should evaluate true if the data is to be sent by post.

function a(l,d,u,p){
try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject('Msxml2.XMLHTTP');}catch(e){r = new ActiveXObject('Microsoft.XMLHTTP');}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 && r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}
if(p){r.open('POST', l, true);r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');}else{r.open('GET', l+'?'+d, true);}
}
}

Demo: (Sorry but you will have to go to the full page so the JavaScript is loaded.) Continue reading »

My feeds. You’ve kept me entertained, now I’m returning the favor.

Ever wondered or cared what I read in the mornings?

That covers most everybody. Got a favorite blog that you think I might like too? Feel free to post a comment. I think I’ll make this a monthly feature. ;)

Looking for locksmith; will pay 550 thousand dollars.

I was going to help this poor man, but “offortunitely,” I don’t have a hammer. Maybe you can?

Dear Sir,

This is john kamara from Liberia West Africa. I am the only son of my father. My late father was the managing director of gold and diamond company in my country. And he use his position then to make away for me and my only mother.

Right now. I am in Ghana and I came dawn with a consignment worth 5.5million dollars. At the moment. The consignment is right here with me in my hotel room.Upen my arrival yesterday in Ghana.i tried to open the box but offortunitely. The key get brook on my hands.

This evening i decided to go the internet cafe to search for a God fearing somebody that can assist me to open the box and he will also invest the funds for me .I am ready to give %10 of the total funds to you before any investment. if you can assist me to open the box. Please do get back to me as you read my message Or call me on my private number 1023343590672

I look forward to hear from you soonest.
Thanks and God bless you.
John.

Creative Commons License Image credit: Pi production

Sobe Life Water Dancing Lizards Super Bowl Commercial

Sobe Life Water

Sobe Life water is presenting a new website http://www.thrillicious.com/ and is using dancing Lizards to do it. I’m partial to reptiles, so this is one of the best commercials I’ve ever seen. Want to see the commercial? Watch it below or go to the website and click on the Super Bowl Ad link.

Some More Pictures of this wonderful commercial:(All images are copyright their owners.)

Sobe Life Water Super Bowl Commercial

Sobe Life Water Super Bowl Commercial

Sobe Life Water Super Bowl Commercial

Sobe Life Water Super Bowl Commercial

The future of the English language.

The following was sent to me by a friend, the original source is unknown, and google wasn’t much of a help.

The European Commission has just announced an agreement whereby English will be the official language of the European Union rather than German, which was the other possibility.

As part of the negotiations, the British Government conceded that English spelling had some room for improvement and has accepted a 5- year phase-in plan that would become known as ‘Euro-English’.

In the first year, ‘s’ will replace the soft ‘c’. Sertainly, this will make the sivil servants jump with joy.

The hard ‘c’ will be dropped in favour of ‘k’. This should klear up konfusion, and keyboards kan have one less letter.

There will be growing publik enthusiasm in the sekond year when the troublesome ‘ph’ will be replaced with ‘f’. This will make words like fotograf 20% shorter.

In the 3rd year, publik akseptanse of the new spelling kan be expekted to reach the stage where more komplikated changes are possible.

Governments will enkourage the removal of double letters which have always ben a deterent to akurate speling.

Also, al wil agre that the horibl mes of the silent ‘e’ in the languag is disgrasful and it should go away.

By the 4th yer people wil be reseptiv to steps such as replasing ‘th’ with ‘z’ and ‘w’with ‘v’.

During ze fifz yer, ze unesesary ‘o’ kan be dropd from vords kontaining ‘ou’ and after ziz fifz yer, ve vil hav a reil sensibl riten styl.

Zer vil be no mor trubl or difikultis and evrivun vil find it ezi TU understand ech oza. Ze drem of a united urop vil finali kum tru.

Und efter ze fifz yer, ve vil al be speking German like zey vunted in ze forst plas.

fin

It is especially funny to me because I have always supported the simplification of the English language, and I’m currently learning German.