Search code examples
.netjquerywcfjson

Json data has {d:"data"}


I am writing jquery ajax code to call wcf service.

In this case WCf returns html as string.

Some how when data is back in jquery it is in {d:"data"} format, What is this d element?

below is code

$.get('<%= ResolveClientUrl("~/AjaxServices/ListingBrowse.svc/GetNewsHTML")  %> ',
  null,
  function(data) {
    alert(data);
    $('#newsdiv').html(data.d);
  },
  "html");

Solution

  • The extra "d" parameter is added by the .NET framework as an added security measure against XSS attacks (source). It's included when the "Content-Type" of the request specifies "application/json".