下拉列表是在coldfusion中使用ajax的另一个下拉列表的基础上填充的,不起作用

下拉列表是在coldfusion中使用ajax的另一个下拉列表的基础上填充的,不起作用,ajax,coldfusion,Ajax,Coldfusion,我在这个网站上搜索了很多,找到了一些类似的帖子,但是他们帮不上忙。我有两个下拉列表。第一个是通过内联查询填充的。第二个需要通过第一个的选择填充。我知道cfselect和cfajaxproxy是最简单的两件事,但我想在不支持它们的Railo上使用它们(选中并返回) ajax代码如下所示: $.ajax({ type: 'POST', url: 'admin/getModelsForManufs.cfc?method=getModels&returnFormat=JS

我在这个网站上搜索了很多,找到了一些类似的帖子,但是他们帮不上忙。我有两个下拉列表。第一个是通过内联查询填充的。第二个需要通过第一个的选择填充。我知道
cfselect
cfajaxproxy
是最简单的两件事,但我想在不支持它们的Railo上使用它们(选中并返回)

ajax代码如下所示:

$.ajax({
      type: 'POST',
      url: 'admin/getModelsForManufs.cfc?method=getModels&returnFormat=JSON',
      data: {manuid:selected},
      dataType: "text",
      success: function(res) {
                  var newoptions = "";
                  for(var i=0; i<res.length; i++) {
                      newoptions += "<option value=\"" + res[i].ID + "\">" + res[i].NAME + "</option>";
                  }
                  $("#model").append(newoptions);
              },
              error: function(x) {
                  alert(x.responseText);
              }
    });
在Firebug中,数据的格式为:

[{"ID":84.0,"NAME":"name 1"},{"ID":1.0,"NAME":"name 2"}] 
这看起来是正确的,并且返回了更多的记录。我已经尝试了大部分的技巧,但是对于为什么第二个下拉列表没有填充,我仍然感到困惑。非常感谢您的帮助。提前谢谢。

试试这段代码

$.ajax({
  type: 'POST',
  url: 'admin/getModelsForManufs.cfc?method=getModels&returnFormat=JSON',
  data: {manuid:selected},
  dataType: "text",
  success: function(res) {
              var res2 = JSON.parse(res);
              var newoptions = "";
              for(var i=0; i<res2.length; i++) {
                  newoptions += "<option value=\"" + res2[i].ID + "\">" + res2[i].NAME + "</option>";
              }
              $("#model").append(newoptions);
          },
          error: function(x) {
              alert(x.responseText);
          }
});
$.ajax({
键入:“POST”,
url:'admin/getModelsForManufs.cfc?method=getModels&returnFormat=JSON',
数据:{manuid:selected},
数据类型:“文本”,
成功:功能(res){
var res2=JSON.parse(res);
var newoptions=“”;

对于(var i=0;必填字段的iDefault值有点违背了强制的目的。另外,这个函数对url了解多少?在任何情况下,回到基础。当您严格使用cf(即不使用ajax)运行函数时,函数是否工作?Railo不支持cfselect和cfajaxproxy?您确定吗?检查并+1 Dan说的,mak在尝试使用AJAX之前,请确保cfc工作正常。其次,您告诉AJAX返回的
dataType
是“text”,但在URL中您指定了JSON的
returnFormat
。将您的AJAX
dataType
更改为“JSON”,看看会发生什么。
$.ajax({
  type: 'POST',
  url: 'admin/getModelsForManufs.cfc?method=getModels&returnFormat=JSON',
  data: {manuid:selected},
  dataType: "text",
  success: function(res) {
              var res2 = JSON.parse(res);
              var newoptions = "";
              for(var i=0; i<res2.length; i++) {
                  newoptions += "<option value=\"" + res2[i].ID + "\">" + res2[i].NAME + "</option>";
              }
              $("#model").append(newoptions);
          },
          error: function(x) {
              alert(x.responseText);
          }
});