I have a .NET webmethod that I have called from jQuery. The method returns some HTML markup that I display within a DIV element.
Once I have the response I use
$("#div").html(result.d);
My question is, what does the .d do? I don't like using code I don't fully understand? Could I get the same result using Eval?
Those backslashes are escape characters. They are escaping the special characters inside of the string associated with JSON response. You have to use JSON. parse to parse that JSON string into a JSON object.
JSON Syntax RulesData is in name/value pairs. Data is separated by commas. Curly braces hold objects. Square brackets hold arrays.
What is JsonResult ? JsonResult is one of the type of MVC action result type which returns the data back to the view or the browser in the form of JSON (JavaScript Object notation format). In this article we will learn about JsonResult by taking scenario to bind view using the JSON Data .
Data is represented in name/value pairs. Curly braces hold objects and each name is followed by ':'(colon), the name/value pairs are separated by , (comma). Square brackets hold arrays and values are separated by ,(comma).
Are you referring to the ADO.NET Data Services?
I remember hearing a presentation about the JSON returning this and I think its just a wrapper to ensure the payload is a JSON object as opposed to an array (which is the case of returning multiple entities).
Why 'd' specifically? I think I remember them saying something like 'well it had to be something'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With