I am working with DevExtreme. I am trying receive JSON from web api server using ajax.
function getJSONfunction()
{
$.ajax({
url: 'http://localhost:999/api/CheckNotification?machinename=LENOVO-PC',
type: "Get",
dataType: 'json',
success: function (data) {
alert('ok');
}
})
I am expecting received from web api json object like this:
{"Result":"true"}
But problem is, web api is sending object like this:
"{\"Result\":\"true\"}"
And I can't see alert from getJSONfunction().
In web api "Get" function look like this:
public string Get(string machineName)
{
int NotificationsNumber = NotificationsFunctions.CheckForNotifications(machineName);
NotificationsResult result = new NotificationsResult();
if(NotificationsNumber > 0)
{
result.Result = "true";
}else
{
result.Result = "false";
}
JavaScriptSerializer js = new JavaScriptSerializer();
string json = js.Serialize(result);
return json;
}
where "NotificationsResult" is a class
public class NotificationsResult
{
public string Result { get; set; }
}
And my question is how can I received JSON object from api in correct format?