Dropdownlist没有使用Ajax Json填充 [英] Dropdownlist is not populating using Ajax Json
问题描述
亲爱的专家,
我正在做一个ASP.net项目。在这里,我使用了ajax JSON来传输数据。
我有两个Dropdownlist。一个填充在页面加载,另一个填充在第一个下拉列表selectchange。
i已经在ajax json方法中使用了这些...
以下是我用过的以下代码...
Dear Experts,
I am doing an ASP.net project. here i have used ajax JSON to transfer the datas.
I have two Dropdownlist . one is populate on Page load, and another is to populate in first dropdownlist selectchange .
i have used these all in ajax json method...
Here is the Below code that am used...
$('#ddl_Standard').change(function () {
$.ajax(
{
type: "POST",
url: "../../WebService.asmx/populate_Division",
dataType: "json",
data: JSON.stringify({ "Standard_ID": document.getElementById('ddl_Standard').value }),
contentType: "application/json; charset=utf-8",
success: function (json) {
var xmlDoc = "";
var xml = "";
xmlDoc = $.parseXML(json.d);
xml = $(xmlDoc);
$(xml).find("Table1").each(function () {
var Division_ID = $(this).find("Division_ID").text();
var Division = $(this).find("Division").text();
$("#ddl_Division").append("<option value='" + Division_ID + "'>" + Division + "</option>");
});
}
});
});
但它没有影响..有时这段代码工作正常......但是有时候它不起作用......请你帮我解决这个问题。
我已经检查了Inspect Element,我可以看到值受到影响..但是没有在下拉控件中填充......
谢谢和问候
Dileep
but it is not affecting.. Sometimes this code is working fine.. but some times it is not working... Can u please help me to solve this.
I have checked in Inspect Element and i can see the values are affected.. but not populated in dropdown control......
Thanks and Regards
Dileep
推荐答案
(' #ddl_Standard')。change( function (){
('#ddl_Standard').change(function () {
.ajax(
{
类型: POST,
url: ../../ WebService.asmx / populate_Division,
dataType: json,
data: JSON .stringify({ Standard_ID: document .getElementById(' ddl_Standard')。value}),
contentType: application / json; charset = utf-8,
成功: function (json){
var xmlDoc = ;
var xml = ;
xmlDoc =
.ajax( { type: "POST", url: "../../WebService.asmx/populate_Division", dataType: "json", data: JSON.stringify({ "Standard_ID": document.getElementById('ddl_Standard').value }), contentType: "application/json; charset=utf-8", success: function (json) { var xmlDoc = ""; var xml = ""; xmlDoc =
.parseXML(json.d);
xml =
.parseXML(json.d); xml =
这篇关于Dropdownlist没有使用Ajax Json填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!