/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

(function($) {

    ajax_generate_option=(function(id,url,data,selectValue){
        id = "#"+id;
        url += "?xxxx="+new Date().getTime();
        $.ajax({
            cache: false,
            url: url,
            data: data,
            dataType: 'json',
            success: function (j) {
            
                var options = [], i = 0, o = null;
                $(id).empty();
                var options = "";

                for (i = 0; i < j.length; i++) {
                    if(j[i].id==selectValue){
                        options += "<option selected value=\"" + j[i].id + "\">" + j[i].text + "</option>";
                    }else{
                        options += "<option  value=\"" + j[i].id + "\">" + j[i].text + "</option>";
                    }
                             
                }
                $(id).html(options);
            },
            error: function (xhr, desc, er) {
                alert(xhr.responseText);
            // add whatever debug you want here.
            //alert("an error occurred");
            }
        });
    });

})(jQuery);


