var FJAjaxInclude = function(){};

FJAjaxInclude.prototype.update = function(id, url, js) {
    this.id = id;
    this.js = js;
    new Ajax.Request(
        url,
        {
            onComplete : this.success.bind(this),
            onFailure : this.failure.bind(this),
            method : 'get'
        }
    );
};

FJAjaxInclude.prototype.success = function(resp) {
    if (this.id) {
        var elm = document.getElementById(this.id);
        if (typeof resp.responseText != 'undefined') {
            elm.innerHTML = resp.responseText;
            if (this.js) {
                this.js();
            }
        }
        else {
            elm.innserHTML = 'レスポンスがありません。';
        }
    }
};

FJAjaxInclude.prototype.failure = function(resp) {
    if (this.id) {
        var elm = document.getElementById(this.id);
        elm.innerHTML = 'error : ' + resp.status;
    }
};
