今天写ligerui三级联动读取数据总是报错:
调用方法:
$.post("../Data1/Sql_Ssx.ashx?Action=QXbyC", {}, function (result) {
$("#tCity").ligerGetComboBoxManager().clearContent();
$("#tCity").ligerGetComboBoxManager().setData(result);
// $("#tCity").ligerGetComboBoxManager().updateStyle();
});
json字符串没有问题 数据返回没有问题 字符串绑定调试一直报错以为读取的数据格式不正确 其实不是post调用返回的是字符串而ligerui绑定设置数据要求是json对象
使用如下方法:
$.getJSON(("../Data1/Sql_Ssx.ashx?Action=QXbyC",
function (json) {
$("#tCity").ligerGetComboBoxManager()..setData(json); //把json塞到下拉框里面去
}
);
就没有问题 因为 getjson 返回的数据格式格式化为json对象或者数组了 而post没有所以post的数据需要eval() 这样就没有问题了
$.post("../Data1/Sql_Ssx.ashx?Action=QXbyC", {}, function (result) {
$("#tCity").ligerGetComboBoxManager().clearContent();
// $("#tCity").ligerGetComboBoxManager().updateStyle();
});
//或者声明的时候:赋值给一个变量 通过对象变量改变值
var gcity1 = $("#tCity").ligerComboBox({
data:'',
valueField: 'code',
textField: 'name',
selectBoxWidth: 140,
autocomplete: true,
width: 140,
initValue: 0,
isMultiSelect: false,
onSelected: function (newvalue) {
getcity(gcity2, "../Data1/Sql_Ssx.ashx?Action=QXbyC&city_val=" + newvalue)
}
});
gcity1.setData(data)