使用JSON控制器从移动应用程序中的jQuery绑定下拉列表时出现问题 [英] Problem when bind dropdown from jquery in mobile application using json controller
问题描述
尊敬的先生
我想在移动应用程序中的其他下拉列表中选择索引已更改的事件上填充下拉列表. dropdwon绑定代码如下.
Dear sir
I want to fill dropdown on other dropdown selected index changed event in a mobile application. dropdwon binding code is following.
<script type="text/javascript">
function drpbrandChange(id) {
ShowModels(document.getElementById(id).value);
}
function ShowModels(CarSefUrl) {
var param = { _CarSefUrl: CarSefUrl };
var data2;
var _url = "JSON/GetCarModelThroughCarSefUrl_New";
var _data = param;
var result = null;
$.ajax({
url: _url,
cache: false,
async: false,
data: _data,
success: function (data)
{
result = data;
},
dataFilter: function (data)
{
if (typeof (JSON) != ''undefined'' && typeof (JSON.parse) == ''function'')
if (typeof (JSON.parse(data)) == "object")
data2= JSON.parse(data);
else
data2 = data;
else
data2 = eval(''('' + data + '')'');
},
error: function ()
{
result = false;
}
});
if (data2 != undefined) {
var items = "<option value=\"\">Select Model...</option>";
var obj = "#drpModel";
if (data2 != null) {
$.each(data2, function (i, data2) {
items += "<option value=" + data2["ModelName"] + ">" + data2["ModelSefUrl"] + "</option>";
});
$(obj).html(items);
}
}
}
</script>
此代码在台式机上成功执行,但在移动设备上无法正常运行,此代码在某些情况下执行.我在三星,blackbarry和endroid手机中测试.
在此先感谢您.
this code is executing successfully in desktop but not working properly in mobile this code is executing some rare case. I test in samsung,blackbarry and endroid mobile phone.
Thanks in advance.
推荐答案
.ajax({ 网址:_url, 快取:false, 异步:错误, 数据:_data, 成功:功能(数据) { 结果=数据; }, dataFilter:函数(数据) { if(typeof(JSON)!=``未定义''&& typeof(JSON.parse)==``函数'') 如果(typeof(JSON.parse(data))==对象") data2 = JSON.parse(数据); 别的 data2 =数据; 别的 data2 = eval(''(''+ data +'')''); }, 错误:函数() { 结果=假; } }); 如果(data2!=未定义){ var items =< option value = \" \>选择模型...</option>"; var obj ="#drpModel"; if(data2!= null){
.ajax({ url: _url, cache: false, async: false, data: _data, success: function (data) { result = data; }, dataFilter: function (data) { if (typeof (JSON) != ''undefined'' && typeof (JSON.parse) == ''function'') if (typeof (JSON.parse(data)) == "object") data2= JSON.parse(data); else data2 = data; else data2 = eval(''('' + data + '')''); }, error: function () { result = false; } }); if (data2 != undefined) { var items = "<option value=\"\">Select Model...</option>"; var obj = "#drpModel"; if (data2 != null) {
.each(data2,function(i,data2){ items + =< option value =" + data2 ["ModelName"] +>" + data2 ["ModelSefUrl"] +</option>"; });
.each(data2, function (i, data2) { items += "<option value=" + data2["ModelName"] + ">" + data2["ModelSefUrl"] + "</option>"; });
(obj).html(items); } } } </script>
(obj).html(items); } } } </script>
此代码在台式机上成功执行,但在移动设备上无法正常运行,此代码在某些罕见情况下执行.我在三星,blackbarry和endroid手机中测试.
预先感谢.
this code is executing successfully in desktop but not working properly in mobile this code is executing some rare case. I test in samsung,blackbarry and endroid mobile phone.
Thanks in advance.
这篇关于使用JSON控制器从移动应用程序中的jQuery绑定下拉列表时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!