JSON not working with Wookmark-Collection of common programming errors
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;
$('#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 += '
Necklaces14like it!
'; } // Add image HTML to the page. $('#tiles').append(html); // Apply layout. applyLayout(); }, error: function(result) { $('#qqq').text(JSON.stringify(result)); //alert(JSON.stringify(result)); } }); };
Webservice:
_
_
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 Output:
[{"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}]
Error:
{"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
Server Error in '/EntLib5' Application.
\r\n\r\n
Request format is unrecognized for URL unexpectedly ending in '/GetCategories'.
\r\n\r\n \r\n\r\n 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.\r\n\r\n
\r\n\r\n Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetCategories'.
\r\n\r\n Source Error:
\r\n\r\n\r\n \r\n \r\n \r\n
\r\n \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. \r\n\r\n |
\r\n\r\n
\r\n\r\n Stack Trace:
\r\n\r\n \r\n \r\n \r\n \r\n
\r\n
\r\n\r\n |
\r\n\r\n
\r\n\r\n \r\n\r\n Version Information: Microsoft .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”,”status”:500,”statusText”:”Internal Server Error”}