So I have my web service which is a WCF and it supports JSON.
When i enter this url
http://localhost/HelloWorldWebService/HelloWorld.svc/getperson
in my browser it returns
{“GetPersonResult”:{“FirstName”:”John”,”LastName”:”Doe”}}
Now I have the following jquery:
function CallService() {
$.ajax({
url: "../HelloWorldWebService/HelloWorld.svc/getperson",
type: "GET",
dataType: "json",
processdata: true,
contentType: "application/json; charset=utf-8",
success: function (msg) {
alert('success');
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
}
$(document).ready(function () { CallService(); });
it shoes the success pop-up …
how can I show the content of the msg in my pop-up?
I tried alert(msg) but it shows [object Object] ???
EDIT: This is what i get when using Firebug with console.log(msg)

So how do I access the FirstName to display it in the alert?
EDIT:
So finally found out how the syntax works. So to get the firstname I had to do
alert(msg.GetPersonResult.FirstName);
Try logging it to the console, so you can see the properties returned by the “msg” object. You can then output the data.
It will output your msg object, you can then access variables such as msg.data if that is what it returns.