【问题标题】:JSON not working with WookmarkJSON 不能与 Wookmark 一起使用
【发布时间】:2012-09-17 19:14:13
【问题描述】:

当我尝试执行以下脚本时..我得到一个error。我正在尝试使用 JSON 接收数据。

function loadData() {
      isLoading = true;
      $('#loaderCircle').show();
      alert("OOOOO");
      $.ajax({

          url: apiURL,
          dataType: 'json',
          data: { page: page }, // Page parameter to make sure we load new data
          success: function(data) {
              isLoading = false;
              $('#loaderCircle').hide();

              // Increment page index for future calls.
              page++;

              // Create HTML for the images.
              var html = '';
              var i = 0, length = data.length, image;
              alert(data.length);
              for (; i < length; i++) {
                  image = data[i];

                  html += '<li class="polaroid"><div class="optionbg"></div><div class="optionback"><span>Necklaces</span></div><div class="options"><span class="favs">14</span><span class="fav">like it!</span></div><a href="http://www.google.co.in"><img src="' + image.preview + '" width="180" height="' + Math.round(image.height / image.width * 180) + '"></a></li>';

              }

              // Add image HTML to the page.
              $('#tiles').append(html);

              // Apply layout.
              applyLayout();
          },
          error: function(result) {
              $('#qqq').text(JSON.stringify(result));
              //alert(JSON.stringify(result));
          }
      });
    };

网络服务:

 <WebMethod(Description:="Gets the Categories")> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function GetCategories() As String
        Dim details As New List(Of Nodes)()

        Using ds As Data.DataSet = db.ExecuteDataSet(CommandType.Text, "SELECT NodeID,NodeName FROM Nodes WHERE ParentID='1'")
            Dim JaggedArray As String()() = New String(ds.Tables(0).Rows.Count - 1)() {}
            Dim i As Integer = 0
            For Each rs As DataRow In ds.Tables(0).Rows
                Dim node As New Nodes()
                node.NodeId = rs("NodeId").ToString
                node.NodeName = rs("NodeName").ToString
                details.Add(node)
                'JaggedArray(i) = New String() {rs("NodeName").ToString(), rs("NodeID").ToString()}
                i = i + 1
            Next
        End Using
        Dim js As New JavaScriptSerializer()
        Dim strJSON As String = js.Serialize(details.ToArray)
        Return strJSON
    End Function

JSON 输出:

<string xmlns="http://localhost:54511/"> [{"NodeId":"BK01","NodeName":"Books","ParentId":null,"Likes":null},{"NodeId":"CO01","NodeName":"Computers","ParentId":null,"Likes":null},{"NodeId":"GA01","NodeName":"Gaming","ParentId":null,"Likes":null},{"NodeId":"MO01","NodeName":"Mobile & Accessories","ParentId":null,"Likes":null}] </string>

错误:

{"readyState":4,"responseText":"&lt;html&gt;\r\n &lt;head&gt;\r\n &lt;title&gt;Request format is unrecognized for URL unexpectedly ending in '/GetCategories'.&lt;/title&gt;\r\n &lt;style&gt;\r\n body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;} \r\n p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top: -5px}\r\n b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top: -5px}\r\n H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red }\r\n H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon }\r\n pre {font-family:\"Lucida Console\";font-size: .9em}\r\n .marker {font-weight: bold; color: black;text-decoration: none;}\r\n .version {color: gray;}\r\n .error {margin-bottom: 10px;}\r\n .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }\r\n &lt;/style&gt;\r\n &lt;/head&gt;\r\n\r\n &lt;body bgcolor=\"white\"&gt;\r\n\r\n &lt;span&gt;&lt;H1&gt;Server Error in '/EntLib5' Application.&lt;hr width=100% size=1 color=silver&gt;&lt;/H1&gt;\r\n\r\n &lt;h2&gt; &lt;i&gt;Request format is unrecognized for URL unexpectedly ending in '/GetCategories'.&lt;/i&gt; &lt;/h2&gt;&lt;/span&gt;\r\n\r\n &lt;font face=\"Arial, Helvetica, Geneva, SunSans-Regular, sans-serif \"&gt;\r\n\r\n &lt;b&gt; Description: &lt;/b&gt;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.\r\n\r\n &lt;br&gt;&lt;br&gt;\r\n\r\n &lt;b&gt; Exception Details: &lt;/b&gt;System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetCategories'.&lt;br&gt;&lt;br&gt;\r\n\r\n &lt;b&gt;Source Error:&lt;/b&gt; &lt;br&gt;&lt;br&gt;\r\n\r\n &lt;table width=100% bgcolor=\"#ffffcc\"&gt;\r\n &lt;tr&gt;\r\n &lt;td&gt;\r\n &lt;code&gt;\r\n\r\nAn 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.&lt;/code&gt;\r\n\r\n &lt;/td&gt;\r\n &lt;/tr&gt;\r\n &lt;/table&gt;\r\n\r\n &lt;br&gt;\r\n\r\n &lt;b&gt;Stack Trace:&lt;/b&gt; &lt;br&gt;&lt;br&gt;\r\n\r\n &lt;table width=100% bgcolor=\"#ffffcc\"&gt;\r\n &lt;tr&gt;\r\n &lt;td&gt;\r\n &lt;code&gt;&lt;pre&gt;\r\n\r\n[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetCategories'.]\r\n System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +405913\r\n System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212\r\n System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47\r\n System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +193\r\n System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93\r\n System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;amp; completedSynchronously) +155\r\n&lt;/pre&gt;&lt;/code&gt;\r\n\r\n &lt;/td&gt;\r\n &lt;/tr&gt;\r\n &lt;/table&gt;\r\n\r\n &lt;br&gt;\r\n\r\n &lt;hr width=100% size=1 color=silver&gt;\r\n\r\n &lt;b&gt;Version Information:&lt;/b&gt;&amp;nbsp;Microsoft .NET Framework Version:2.0.50727.4971; ASP.NET Version:2.0.50727.4971\r\n\r\n &lt;/font&gt;\r\n\r\n &lt;/body&gt;\r\n&lt;/html&gt;\r\n&lt;!-- \r\n[InvalidOperationException]: Request format is unrecognized for URL unexpectedly ending in '/GetCategories'.\r\n at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)\r\n at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)\r\n at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)\r\n at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)\r\n at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)\r\n--&gt;","status":500,"statusText":"Internal Server Error"}

【问题讨论】:

    标签: asp.net vb.net json


    【解决方案1】:
    猜你喜欢
    • 2018-03-26
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-20
    • 1970-01-01
    • 2017-01-09
    • 2017-04-14
    • 2016-09-16
    相关资源
    最近更新 更多