本文介绍了Radiobuttonlist没有使用jquery AJAX调用绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我的点击事件: < div id = btncontinue3 > < 表 > < tr > < td > < 输入 id = btncon3 type = button value = 继续 / > ; < / td > < / tr > ; < / table > < / div > 点击按钮按钮,调用ajax调用。我在页面加载时得到了所有隐藏的值。所以一切都正确通过。 我的ajax调用webmethod [WebMethod(EnableSession = true)] public static string Getmethod(string Country,string Zipcode,string tableName) { DataTable dt = new DataTable(); dt = getdtmethod(); //这里我得到所有值: dt.TableName = tableName; 字符串结果; using(StringWriter sw = new StringWriter()) { dt.WriteXml(sw); result = sw.ToString(); } 返回结果; } 我检查了xml字符串。我想跟随 < DocumentElement > < Ratesval > < code > 11A < / code > < description > Foot Ball < / description > < 提示 > 上午10:30 < /提示 > < via_code > S0 < / via_code > < / Ratesval > < Ratesval > < 代码 > 21A < / code > < description > Volley Ball < / description > < 提示 > 01:30 AM < /提示 > < via_code > P0 < / via_code > < / Ratesval > < / DocumentElement > 我没有收到任何错误:所以,ajax成功方法调用。甚至我找到了表名和代码,描述(使用alert和debuger -checked)。但我认为它不是绑定到radiobuttonlist的。因为单选按钮没有显示在屏幕上。只是空白。 $(#btncontinue3)。click(function(){ debugger; //使用ajax调用计算运费 var country = $( #<% = txtshipcountry.ClientID %> )。val(); var zipcode = $('#<% = hdnvalforzipshipping.ClientID %> ').val(); var tableName ='Ratesval'; var rdbtnlist = $(#<% = rdbtnlistshipping.ClientID %> ); $ .ajax({ type:POST , contentType:application / json; charset = utf-8, url:.. / kout.aspx / Getmethod, data:{'Country':' + country +','Zipcode':'+ zipcode +','tableName':'+ tableName +'}, dataType:json, success:function(response ){ $(response.d).find('Ratesval')。each(function(){ //获取OptionValue和Option文本列值。 var OptionValue = $(this).find('code')。text(); var OptionText = $(this).find('description')。text(); alert(OptionValue); alert(OptionText); //为radiobuttonlist创建一个选项。 var option = $(< 选项 > + OptionText +< / option > ); option.attr(value,OptionValue); rdbtnlist.append(option); }); },错误:函数(结果){ alert(代码错误); } }); }); //使用clientID在jquery中声明和访问radiobuttonlist,因为它是子页面(内容占位符)。 < asp:RadioButtonList ID = rdbtnlistshipping runat = 服务器 > < / asp:RadioButtonList > 解决方案 (#btncontinue3)。click(function(){ debugger; //使用ajax调用计算运费 var country = (#<% = txtshipcountry.ClientID %> )。val(); var zipcode = ('#<% = hdnvalforzipshipping.ClientID %> ')。val(); var tableName ='Ratesval'; var rdbtnlist = My click event:<div id="btncontinue3"><table ><tr><td><input id="btncon3" type="button" value="Continue" /></td></tr></table></div>while click on button Button , calling ajax call. i got the all hidden values on page load. So everything passing correctly.my ajax call webmethod[WebMethod(EnableSession = true)]public static string Getmethod(string Country, string Zipcode, string tableName){DataTable dt = new DataTable();dt = getdtmethod();// here i am getting all values :dt.TableName=tableName;string result;using (StringWriter sw = new StringWriter()){dt.WriteXml(sw);result = sw.ToString();}return result;}i checked xml string. i got like follow<DocumentElement><Ratesval><code>11A</code><description>Foot Ball</description><Hint>10:30 A.M.</Hint><via_code>S0</via_code></Ratesval><Ratesval><code>21A</code><description>Volley Ball</description><Hint>01:30 A.M.</Hint><via_code>P0</via_code></Ratesval></DocumentElement>I did not get any error: So, ajax success method calls. even i found table name and code, description (using alert and debuger -checked). Butit is not binding into radiobuttonlist i guess. becuase radio button is not showing on screen. Just blank.$("#btncontinue3").click(function () {debugger;// calculate shipping rate using using ajax callvar country = $("#<%=txtshipcountry.ClientID%>").val();var zipcode = $('#<%=hdnvalforzipshipping.ClientID%>').val();var tableName = 'Ratesval';var rdbtnlist = $("#<%=rdbtnlistshipping.ClientID%>");$.ajax({type: "POST",contentType: "application/json;charset=utf-8",url:"../kout.aspx/Getmethod",data: "{'Country':'" + country + "','Zipcode':'" + zipcode + "','tableName':'"+tableName+"'}",dataType: "json",success: function (response) {$(response.d).find('Ratesval').each(function () {// Get the OptionValue and OptionText Column values.var OptionValue = $(this).find('code').text();var OptionText = $(this).find('description').text();alert(OptionValue);alert(OptionText);// Create an Option for radiobuttonlist.var option = $("<option>" + OptionText + "</option>");option.attr("value", OptionValue);rdbtnlist.append(option);});},error: function (result) {alert("Error in code");}});});// radiobuttonlist declared and accessed in jquery using clientID as it is child page(content placeholder).<asp:RadioButtonList ID="rdbtnlistshipping" runat="server"></asp:RadioButtonList> 解决方案 ("#btncontinue3").click(function () {debugger;// calculate shipping rate using using ajax callvar country =("#<%=txtshipcountry.ClientID%>").val();var zipcode =('#<%=hdnvalforzipshipping.ClientID%>').val();var tableName = 'Ratesval';var rdbtnlist = 这篇关于Radiobuttonlist没有使用jquery AJAX调用绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-13 13:44