Thank you, John Resig!

by Kofi Sarfo 17. June 2009 04:56

So we had the option of writing some code in order to determine browser responsiveness to see whether the code in the last post - AJAX and the URL short(ening) - was in fact asynchronous... or use jQuery which we know is most definitely AJAX. Really, we're not in the mood for poking under the hood.

There was a wee bit of pain in the why now isn't ths working stakes, some edits later and it did. Mysteriously. So I didn't touch it anymore. A case of Programming by Coincidence?


<script src="Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var getBitlyUrl = function() {

// set up default options
var defaults = {
version: '2.0.1',
login: 'bitlyapidemo',
apiKey: 'R_0da49e0a9118ff35f52f629d2d71bf07',
history: '1',
longUrl: $('#rawUrl').val()
};

// Build the URL to query
var daurl = "http://api.bit.ly/shorten?"
+ "version=" + defaults.version
+ "&longUrl=" + defaults.longUrl
+ "&login=" + defaults.login
+ "&apiKey=" + defaults.apiKey
+ "&history=" + defaults.history
+ "&format=json&callback=?";

$.getJSON(daurl, function(data) {
$('#bladder').empty();
$('#bitlyUrl').val(data.results[defaults.longUrl].shortUrl);
});
}

$('#getUrl').bind('click', getBitlyUrl);
})
(jQuery);
</script>

The body is the same as in the previous post. It's that easy. Great library.

Notes:
One of the leetlest problems we had was with receiving a 'permission denied' error when omitting "&format=json&callback=?" from the default URL. Solution and Nabble discovery all at the same time!

Comments

10/29/2009 5:46:35 PM #

Do you make money out of this blog? just curious

payday loans United States |

11/24/2009 11:07:21 AM #

Searching for this for some time now - i guess luck is more advanced than search engines Smile

payday loans United States |

12/17/2009 1:12:30 AM #

Do you make money out of this blog? just curious

VT Payday Loans United States |

Comments are closed

Kofi Sarfo modified theme by Mads Kristensen



Content by WIMIRO Technology is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.

Creative Commons License

Powered by BlogEngine.NET 1.5.0.7

About Me

Director, Wimiro Technology
London, United Kingdom

Writes in third person and first person plural; currently commutes to Moorgate.

Kiva Loans

  • Issa Sarr

    Issa Sarr

    Personal Purchases

    Requested loan: $200

    Amount raised: $75

    Dakar, Senegal

    social needs

    Loan Now »

  • Edwin

    Edwin

    Movie Tapes & DVDs

    Requested loan: $800

    Amount raised: $125

    La Paz, Bolivia

    Buy a DVD burner tower

    Loan Now »

  • Soo

    Soo

    Laundry

    Requested loan: $5375

    Amount raised: $2175

    Queens, New York, United States

    To purchase a new dry cleaning machine

    Loan Now »

 To see more entrepreneurs »

Kiva Loans