function cityResult() 

   var city=document.getElementById("DropDownList1");
   AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
}
function get_city_Result_CallBack(response)
{
   if (response.value != null)
   {
      //debugger;
      document.all("DropDownList2").length=0;
      var ds = response.value;
      if(ds != null && typeof(ds) == "object" && ds.Tables != null)
      {
         for(var i=0; i<ds.Tables[0].Rows.length; i++)
         {
            var name=ds.Tables[0].Rows[i].city;
            var id=ds.Tables[0].Rows[i].cityID;
            document.all("DropDownList2").options.add(new Option(name,id));
         }
      }
   }
   return
}//===============================================================
在这个JS里面第3行:AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
这个里面的city.value,get_city_Result_CallBack是调用第6行的function get_city_Result_CallBack(response)
但是这个函数带一个参数response,为什么在第3行调用的时候,不用在city.value,get_city_Result_CallBack后面带参数呀??
那么如果我要在第3行的city.value,get_city_Result_CallBack再带一个参数 i 过去,要怎么样写?
是不是city.value,get_city_Result_CallBack("",i)
然后在第6行的改成function get_city_Result_CallBack(response,i)呀??
但是这样的话,我试过不行!!请问应该怎么改呀??

解决方案 »

  1.   

    get_city_Result_CallBack 这是一个回调函数吧?
    你按照它的原型写就可以了,如果原型没提供参数,那么你写了也没用
      

  2.   

    但是我可以在第6行 function get_city_Result_CallBack(response)的(response)改成(response,i)呀,不是吗?
      

  3.   

    改个顺序就行了 get_city_Result_CallBack(i,response)AjaxMethod.GetCityList(city.value,get_city_Result_CallBack("a")); 
      

  4.   

    ==
    你 AjaxMethod.GetCityList 里面怎么写的?不会是 get_city_Result_CallBack(city) 吧?
    我估计GetCityList 里面也要改
      

  5.   

    不行呀!!显示Error:缺少对象
      

  6.   

    #region GetCityList
            [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
            public DataSet GetCityList(int povinceid)
            {
                string sql = "select * from city where father=" + povinceid;
                return GetDataSet(sql);
            }
            #endregionGetCityList 是这样的
      

  7.   

    get_city_Result_CallBack(response)这个回调函数只是用来出里你的返回结果的,你实际传入CS代码的参数是在你的AjaxMethod.GetCityList(***)里传入的。你如果是要传参数到CS后台不应该在回调函数中传,而是在AjaxMethod.GetCityList这里传。如果确实需要在回调函数中使用其他的参数,那你就在js中设置全局变量供回调函数里面使用不就是了。
      

  8.   

    我是要传到回调函数中呀,因为第6行那里document.all("DropDownList2").length=0; 
    它固定了我的控件是DropDownList2,我不可能只有一个这样的控件,我还有其它控件都要实现这个功能
    所以我想把控件的ID传过去,让他去执行