{"id":5673,"date":"2014-04-05T03:37:54","date_gmt":"2014-04-05T03:37:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/05\/json-not-working-with-wookmark-collection-of-common-programming-errors-2\/"},"modified":"2014-04-05T03:37:54","modified_gmt":"2014-04-05T03:37:54","slug":"json-not-working-with-wookmark-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/05\/json-not-working-with-wookmark-collection-of-common-programming-errors-2\/","title":{"rendered":"JSON not working with Wookmark-Collection of common programming errors"},"content":{"rendered":"<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6d759a9e10591c530ff2f1b400637eff?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMonodeep<\/p>\n<p>When i try to execute the following script..i get an <code>error<\/code> .I am trying to receive data using JSON.<\/p>\n<pre><code>function loadData() {\n      isLoading = true;\n      $('#loaderCircle').show();\n      alert(\"OOOOO\");\n      $.ajax({\n\n          url: apiURL,\n          dataType: 'json',\n          data: { page: page }, \/\/ Page parameter to make sure we load new data\n          success: function(data) {\n              isLoading = false;\n              $('#loaderCircle').hide();\n\n              \/\/ Increment page index for future calls.\n              page++;\n\n              \/\/ Create HTML for the images.\n              var html = '';\n              var i = 0, length = data.length, image;\n              alert(data.length);\n              for (; i &lt; length; i++) {\n                  image = data[i];\n\n                  html += '<\/code><\/pre>\n<li class=\"polaroid\"><code>Necklaces14like it!<img decoding=\"async\" src=\"'%20+%20image.preview%20+%20'\" width=\"180\" height=\"' + Math.round(image.height \/ image.width * 180) + '\" \/><\/code><\/li>\n<pre>';\n\n              }\n\n              \/\/ Add image HTML to the page.\n              $('#tiles').append(html);\n\n              \/\/ Apply layout.\n              applyLayout();\n          },\n          error: function(result) {\n              $('#qqq').text(JSON.stringify(result));\n              \/\/alert(JSON.stringify(result));\n          }\n      });\n    };\n<\/pre>\n<p><code><strong>Webservice:<\/strong><\/code><\/p>\n<pre><code><code>  _\n     _\n    Public Function GetCategories() As String\n        Dim details As New List(Of Nodes)()\n\n        Using ds As Data.DataSet = db.ExecuteDataSet(CommandType.Text, \"SELECT NodeID,NodeName FROM Nodes WHERE ParentID='1'\")\n            Dim JaggedArray As String()() = New String(ds.Tables(0).Rows.Count - 1)() {}\n            Dim i As Integer = 0\n            For Each rs As DataRow In ds.Tables(0).Rows\n                Dim node As New Nodes()\n                node.NodeId = rs(\"NodeId\").ToString\n                node.NodeName = rs(\"NodeName\").ToString\n                details.Add(node)\n                'JaggedArray(i) = New String() {rs(\"NodeName\").ToString(), rs(\"NodeID\").ToString()}\n                i = i + 1\n            Next\n        End Using\n        Dim js As New JavaScriptSerializer()\n        Dim strJSON As String = js.Serialize(details.ToArray)\n        Return strJSON\n    End Function\n<\/code><\/code><\/pre>\n<p><strong>JSON Output:<\/strong><\/p>\n<p><code>[{\"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 &amp; Accessories\",\"ParentId\":null,\"Likes\":null}]<\/code><\/p>\n<p><strong>Error:<\/strong><\/p>\n<p><code>{\"readyState\":4,\"responseText\":\"\\r\\n \\r\\n Request format is unrecognized for URL unexpectedly ending in '\/GetCategories'.\\r\\n \\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 \\r\\n \\r\\n\\r\\n \\r\\n\\r\\n<\/code><\/p>\n<h1><code>Server Error in '\/EntLib5' Application.<\/code><\/h1>\n<p><code>\\r\\n\\r\\n<\/code><\/p>\n<h2><code><i>Request format is unrecognized for URL unexpectedly ending in '\/GetCategories'.<\/i><\/code><\/h2>\n<p><code>\\r\\n\\r\\n \\r\\n\\r\\n <b>Description:<\/b> 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<\/p>\n<p>\\r\\n\\r\\n <b>Exception Details:<\/b> System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '\/GetCategories'.<\/p>\n<p>\\r\\n\\r\\n <b>Source Error:<\/b><\/p>\n<p>\\r\\n\\r\\n<\/code>\\r\\n \\r\\n \\r\\n \\r\\n<\/p>\n<table width=\"100%\" bgcolor=\"\\&quot;#ffffcc\\&quot;\">\n<tr>\n<td>\\r\\n <code>\\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.<\/code>\\r\\n\\r\\n<\/td>\n<\/tr>\n<\/table>\n<p>\\r\\n\\r\\n<br \/>\n\\r\\n\\r\\n <b>Stack Trace:<\/b><\/p>\n<p>\\r\\n\\r\\n \\r\\n \\r\\n \\r\\n \\r\\n<\/p>\n<table width=\"100%\" bgcolor=\"\\&quot;#ffffcc\\&quot;\">\n<tr>\n<td>\\r\\n<\/p>\n<pre><code>\\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; completedSynchronously) +155\\r\\n<\/code><\/pre>\n<p>\\r\\n\\r\\n<\/td>\n<\/tr>\n<\/table>\n<p>\\r\\n\\r\\n<br \/>\n\\r\\n\\r\\n \\r\\n\\r\\n <b>Version Information:<\/b>\u00a0Microsoft .NET Framework Version:2.0.50727.4971; ASP.NET Version:2.0.50727.4971\\r\\n\\r\\n \\r\\n\\r\\n \\r\\n\\r\\n&#8221;,&#8221;status&#8221;:500,&#8221;statusText&#8221;:&#8221;Internal Server Error&#8221;}<\/li>\n","protected":false},"excerpt":{"rendered":"<p>Monodeep When i try to execute the following script..i get an error .I am trying to receive data using JSON. function loadData() { isLoading = true; $(&#8216;#loaderCircle&#8217;).show(); alert(&#8220;OOOOO&#8221;); $.ajax({ url: apiURL, dataType: &#8216;json&#8217;, data: { page: page }, \/\/ Page parameter to make sure we load new data success: function(data) { isLoading = false; $(&#8216;#loaderCircle&#8217;).hide(); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5673","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5673"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5673\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}