Reputation: 11
Using Visual Studio 13. How to use the data
in success function of ajax call? it shows "intellisense was unable to determine an accurate completion list for this expression" every time i select the name after data.
When I alert data
it has no error and works fine, but when alert data.d
it shows data.d
is Undefined.
$.ajax({
url: "Service.svc/GetEventTimeSlots",
data: '{ "eventDate": "' + $("input[id$=hidVisitDate]").val() + '"}',
//dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function(data) {
alert(data.d); // message prompt "undefined"
}
});
I have already added _references.js
into (intellisense at option), but still it is not working
I need successful result when i use alert(data.d)
Upvotes: 1
Views: 79
Reputation: 1213
Try this.
newdata = JSON.parse(data);
alert(newdata[0].d);
you might be missing this parse
.
Upvotes: 1
Reputation: 2121
Use jQuery to parse the JSON data.
var parsed_data = jQuery.parseJSON(data);
alert(parsed_data.d);
Upvotes: 1
Reputation: 21
You dont't need _references.js. Your webservice function GetEventTimeSlots is a GET or a POST function? Maybe you have to change the type of your AJAX method.
Upvotes: 1