1

My web service call returns this into data1

"{"d":"PCIS Follow Add ID and Codes when printed"}"

I learne that when using jquery with asp.net i must use data1.d

however when i try to do alert(data.d);

i get undefined returned even though data.d value shows as

"{"d":"PCIS Follow Add ID and Codes when printed"}"

any ideas on how i can use this information

the web service should be returning a string

 $.ajax({
                type: "POST",
                url: "Services/WorkService.asmx/WorkDescription",
                data: "{'workUnitId' : '" + $("option:selected", $(dropdown)).text() + "','id': '" + combobox.val() + "'}",
                contentType: "application/json; charset=utf-8",
                dataType:"json",
                success: function(data1) {
                var jsObject = JSON.parse(data1.d);
            alert(jsObject);                   
 combobox.attr("_tooltip", data1.d);    
                }    
            });
        },
HELP_ME
  • 2,619
  • 3
  • 24
  • 31

2 Answers2

4

you should set json as dataType

 dataType:"json",

because if you specify text jQuery won't parse the response (if you specify json jQuery calls $.parseJSON() on the response)

Look at my answer in this question Why is 'jQuery.parseJSON' not necessary?

EDIT your server should return

{"d":"PCIS Follow Add ID and Codes when printed"}

withouth the starting and trailing "

Community
  • 1
  • 1
Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
0

Try this:

<script>
var jsObject = JSON.parse('{"hello":"world"}');
alert(jsObject.hello);
</script>
Aram Kocharyan
  • 20,165
  • 11
  • 81
  • 96