JQuery AJAX responseText to JSON

Posted by BoredOfBinary on Stack Overflow See other posts from Stack Overflow or by BoredOfBinary
Published on 2010-04-23T22:00:18Z Indexed on 2010/04/23 22:03 UTC
Read the original article Hit count: 230

Filed under:
|

I have this script that calls a .net WebService

            msg = $.toJSON(
                    $.ajax({
                        type: "POST",
                        url: "http://[url]/ETS.UI/WebServices/LocationService.asmx/GetMappingLocationDetails",
                        contentType: "application/json; charset=utf-8",
                        data: $.toJSON({'componentId':994}),
                        dataType: "json",
                        async: false
                    }).responseText
            );

And I recieve the following value in the msg variable:

""{\"d\":\"{\\"ComponentId\\":994,\\"Latitude\\":32.219627009236405,\\"Longitude\\":-110.96843719482422,\\"LocationName\\":\\"Tucson\\",\\"StreetAddress\\":\\"7201 E 22nd Street \\",\\"City\\":\\"Tucson\\",\\"State\\":\\"AZ\\",\\"PostalCode\\":null}\"}""

I have no idea why this would format this way, seems to only do this in responseText.

Does anyone have any ideas?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ajax