﻿//ajax请求函数
function AjaxRequstFn(FID, id, vbt, urlv) {
    $('#' + id).html("<option value='0'>" + vbt + "</option>");
    if ($('#' + FID).val() != null) {
        $.ajax({
            type: 'GET',
            url: urlv,
            processData: false,
            dataType: 'text',
            data: 'id=' + escape($('#' + FID).val()),
            success: function (data) {
                FormatData(data, id, vbt); //格式化字符串
            }
        });
    }
};
//格式化字符串
function FormatData(data, id, vbt) {
    if (data != "") {
        var items = data.split('$');
        var value = '';
        var text = '';
        for (var i = 0; i < items.length; i++) {
            var itarr = items[i].split(',');
            value = itarr[0];
            text = itarr[1]
            $('#' + id).append('<option value="' + value + '">' + text + '</option>');
        }
    }
}
function AjaxRequstFn1(FID, id, hid, vbt, vtypes, urlv) {
    $('#' + id).html("<option value='0'>" + vbt + "</option>");
    if ($('#' + FID).val() != null) {
        $.ajax({
            type: 'GET',
            url: urlv,
            processData: false,
            dataType: 'text',
            data: 'id=' + escape($('#' + FID).val()) + '&vtypes=' + escape(vtypes),
            success: function (data) {
                FormatData1(data, id, hid, vbt); //格式化字符串
            }
        });
    }
};
//格式化字符串
function FormatData1(data, id, hid, vbt) {
    if (data != "") {
        var depth = parseInt($('#' + hid).val()) + 1;
        $('#' + hid).val(depth);
        var items = data.split('$');
        var value = '';
        var text = '';
        for (var i = 0; i < items.length; i++) {
            var itarr = items[i].split(',');
            value = itarr[0];
            text = itarr[1]
            $('#' + id).append('<option value="' + value + '">' + text + '</option>');
        }
    }
}
