Hello everyone,
I have made one Rest service in WCF (demo) , which gives me output as : {"GetEmployeeJSONResult":{"Id":101,"Name":"Sumanth","Salary":5000}}
Now i have created one website in asp.net in which i am calling this rest service through AJAX JSON...
my code is as below:
<script type="text/javascript">
$(document).ready(function () {
var endpointAddress = "http://localhost/SampleService/Service1.svc";
var url = endpointAddress + "/GetJson";
$.ajax({
type: 'GET',
url: url,
dataType: 'jsonp',
contentType: 'application/json',
data: "{}",
success: function (result) {
alert(result.length);
},
error:function(jqXHR)
{
alert(jqXHR.status);
}
});
});
</script>
You could see that i have accessed service through both AJAX and getJSON methods..
now when i am making a alert of data , it shows me output as undefined..
i have tried :
alert(result.d.length) , alert(result.d.GetEmployeeJSONResult)... but always shows me as undefined..in both methods..
Please help me out how to handle this..
Thanking you in advance.
Krunal