C# Ajax调用Parm字符串,返回JSON列表

C# Ajax调用Parm字符串,返回JSON列表,c#,javascript,ajax,json,C#,Javascript,Ajax,Json,我试图在AJAX调用帖子中传递一个字符串,以检索JSON中的列表 以下是触发调用的代码: <script> var a = {}; a.theatreList = <%= Newtonsoft.Json.JsonConvert.SerializeObject(TheatreList) %> ; $(document).ready(function () { $("button").click(function () {

我试图在AJAX调用帖子中传递一个字符串,以检索JSON中的列表

以下是触发调用的代码:

<script>

    var a = {};

    a.theatreList = <%= Newtonsoft.Json.JsonConvert.SerializeObject(TheatreList) %> ; 
    $(document).ready(function () {
        $("button").click(function () {
          //  if (a.theatreList != null){                
                //ko.applyBindings(new theatreSel.TheatreModel(a.theatreList));
                ko.applyBindings(new theatreSel.TheatreModel(a.theatreList));
                Regal.showLocationModal();
                return false;

          //  }
        });
      });

</script>
最后是.asmx

namespace Regal.Web.Services
{
    /// <summary>
    /// Summary description for TheatreLocationList
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class TheatreLocationList : System.Web.Services.WebService
    {

        [WebMethod]
        public List<dynamic> getTheatres(String zip)
        {
            List<dynamic> TheatreList = new List<dynamic>();
            int radius = Regal.Core.Helpers.ConfigHelper.GetIntValue("SearchRadius", 30);
            IFrdiTheatreRepository frdiTheatreRepo = FrdiTheatreRepository.CreateBusinessObject();
            TheatreCollection theatreCollection = frdiTheatreRepo.GetAllTheatresFromRegalByPostalCode("60613", radius);
            TheatreList = theatreCollection.ToList<dynamic>();
            return TheatreList;


        } 
    }
}


    })(window)

您是否已将HttpGet和HttpPost协议添加到web配置中?看,这不是问题,我们有其他程序使用这个。我的问题实际上更窄,要让我的数据类型在JSON中正确返回。显然,我必须返回JSON格式的列表,但这部分有问题。谢谢你的回复
namespace Regal.Web.Services
{
    /// <summary>
    /// Summary description for TheatreLocationList
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class TheatreLocationList : System.Web.Services.WebService
    {

        [WebMethod]
        public List<dynamic> getTheatres(String zip)
        {
            List<dynamic> TheatreList = new List<dynamic>();
            int radius = Regal.Core.Helpers.ConfigHelper.GetIntValue("SearchRadius", 30);
            IFrdiTheatreRepository frdiTheatreRepo = FrdiTheatreRepository.CreateBusinessObject();
            TheatreCollection theatreCollection = frdiTheatreRepo.GetAllTheatresFromRegalByPostalCode("60613", radius);
            TheatreList = theatreCollection.ToList<dynamic>();
            return TheatreList;


        } 
    }
}


    })(window)
Server Error in '/' Application.

Request format is unrecognized for URL unexpectedly ending in '/getTheatres'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/getTheatres'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/getTheatres'.]
   System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +713331
   System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +308
   System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +89
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +516
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288