I am making calls to my backend to populate an observableArray like so:
$.ajax({
url: 'www.data.net/api/....',
type: 'GET',
dataType: 'jsonp',
crossDomain: true,
success: function (data) {
dataHolder(data);
},
error: function (xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
Backend method:
[Route("Api/mydata/GetMyContent/{postPageName}"), HttpGet]
public HttpResponseMessage GetMyContent(string postPageName)
{
var result = mydataRepository.GetMyContent(postPageName);
return Request.CreateResponse(result == null ? HttpStatusCode.OK :
HttpStatusCode.Forbidden, result);
}
Right now your backend method only returns "200 - OK" if the page you selected has no content. Otherwise if the page has some content you always return 403.
I kinda feel that you just might have inadvertently changed your ternary operator?
Maybe try:
return Request.CreateResponse(result == null ? HttpStatusCode.Forbidden:
HttpStatusCode.OK, result);