Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ajax无法调用asp.net web方法_C#_Javascript_Jquery_Asp.net_Ajax - Fatal编程技术网

C# ajax无法调用asp.net web方法

C# ajax无法调用asp.net web方法,c#,javascript,jquery,asp.net,ajax,C#,Javascript,Jquery,Asp.net,Ajax,我在ajax调用中调用asp.net web方法。Web方法如下所示 [WebMethod()] public static int DropDownIndexChanged(string selectedText) { int a = 5; // This is just to test return a; } 在我的ajax调用中,我在一个下拉列表中发送所选的值,具有id下拉列表,如下所示 $.ajax({ type: "POST",

我在ajax调用中调用asp.net web方法。Web方法如下所示

[WebMethod()]
public static int DropDownIndexChanged(string selectedText)
{
   int a = 5; // This is just to test
   return a;
}
在我的ajax调用中,我在一个下拉列表中发送所选的值,具有id下拉列表,如下所示

$.ajax({
              type: "POST",
              url: "FindFines.aspx/DropDownIndexChanged",
              data: { "selectedText":"+$("#DropDown option:selected").text()+"},
              success: function (data) {
                    alert("Success");
              }
});
但函数并没有被调用。请指导我做这件事的正确方法。谢谢。

我想你的问题是+$DropDown选项:selected.text+

请换

 [WebMethod()] 


你有没有检查Firebug>里面显示了什么错误?
 [WebMethod()] 
 [WebMethod]
 data: { "selectedText":"+$("#DropDown option:selected").text()+"}
  data: '{selectedText: "' + $("#DropDown option:selected").text() + '" }'