// ajaxHandler


// postData class definition (mainly for toString purposes)
function postData()
{

this.data = 0;

this.toString = function () {
    var re = ' ';
    for(p in this.data) {
        re += p + '->' + this.data[p] + ' | ';
    }
    return re;
}
    
}


// handler class definition
function AjaxHandler(backendUrl)
{
    
    var pd = new postData();
    
    this.backend = backendUrl;

    this.setData = function(data) {pd.data = data;}
    
    this.setBackend = function(burl) {this.backend = burl;}
    
    this.Post = function(c_function, dtype)
    {
        $.post(this.backend, pd.data,
        function(data) {
            if(data.error) {
                alert(data.text + '\nSent:' + pd);
            }
            else {
                eval(c_function + "(data);");
            }
        }, dtype);   
    }
       
}


