Pure client-side call to Twitter API

I have already figured out how to update someone’s Twitter status using PHP’s curl. These are the 3 major lines:


curl_init('http://twitter.com/statuses/update.xml');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'status=my new twitter status');
curl_setopt($ch, CURLOPT_USERPWD, 'myUsername:myPassword');

I was wondering if I could take load off of my server by not using curl. Would it be possible to directly call the twitter.com URL with AJAX? How do you do this “Basic Authentication” protocol with AJAX?

I’m using Prototype.js and I’m having difficulty finding articles on it. So far, I have this. It lacks the Basic Authentication part, so it will fail.


new Ajax.Request(
    'http://twitter.com/statuses/update.json', {
        method: 'post',
        parameters: {
            status: 'my new twitter status'
        }
    }
);