2014年3月19日水曜日

開発環境

Head First JavaScript ―頭とからだで覚えるJavaScriptの基本( Michael Morrison (著), 豊福 剛 (翻訳)、オライリージャパン)の12章(ダイナミックなデータ)、JavaScriptマグネット(p.557)を解いてみる。

その他参考書籍

JavaScriptマグネット(p.557)

コード(BBEdit)

ajax.js

var AjaxRequest = function () {
    // 
};

AjaxRequest.prototype.send = function (type, url, handler, post_data_type, post_data) {
    if(this.request !== null) {
        this.request.abort();
        url += "?dummy=" + new Date().getTime();
        
        try {
            this.request.onreadystatechange = handler;
            this.request.open(type, url, true);
            
            if (type.toLowerCase() === 'get') {
                this.request.send(null);
            } else {
                this.request.setRequestHeader('Content-Type', poast_data_type);
                this.request.send(post_data);
            }
        } catch (e) {
            alert('サーバとの通信でAjaxエラー\n' + '詳細: ' + e);
        }
    }
};

0 コメント:

コメントを投稿