Reputation: 2915
I have a small problem, with my webservice call. I've debugged it, and the webservice gets called, with the correct value and it also returns the correct value. However, my alert (in the completed function)says: 'undefined'. What am I doing wrong? Here's my function:
function GetServiceValue() {
var Parameter = "{contextKey: '" + $('#<%= ProjectNumText.ClientID %>').val() + "'}";
alert('Para: ' + Parameter);
$.ajax({
type: 'Post',
url: 'DynamicPopulateService.asmx/GetProjectName',
data: Parameter,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
AjaxSucceeded(msg);
},
error: AjaxFailed
});}
And here is the completed function:
function AjaxSucceeded(data)
{
alert(data.responseText);
}
Upvotes: 2
Views: 4361
Reputation: 9619
It looks like you're using ASP.NET. ASP.NET script services return the JSON response under a wrapper object called simply "d". Try this:
function AjaxSucceeded(data)
{
alert(data.d.responseText);
}
Upvotes: 3