views:

547

answers:

2

I have a webmethod that returns a Hashtable through a jQuery ajax call along the lines of:

$.ajax({
   type: "POST",
   url: webMethod,
   data: {}
   contentType: "application/json; charset=utf-8",
   dataType: "json",
   success: function(json){
      **alert(json.d);**
   },
   error: function(XMLHttpRequest, textStatus, errorThrown) {
      alert(textStatus);
   }
});

My problem is, when I deploy it to the server json.d is undefined, but instead json is the hashtable. On my local box its the opposite json.d is the hastable and not the json object.

I've traced it back to a point where I can see that the returned JSON string is sometimes {d:{}} and on the server its {}.

Does anybody know why?

+1  A: 

I try and use this firefox plugin to see what the json data looks like

https://addons.mozilla.org/en-US/firefox/addon/10869/

it formats all the json coming back nicely so you can see what your object looks like.

Nick
A: 

Turns out this depends on the .net framework version your using. If your using 3.5 they add the Json.d variable as a security measurement. If you using framework 3.0 it does not appear.

Kwan Cheng