I am trying to read data from a CosmosDB using an Ajax call and want data in JSON format.
Controller
[ActionName("Status")]
public async Task<ActionResult> Status(string id, string partitionKey)
{
if (id == null)
{
return BadRequest();
}
Item item = await _cosmosDbService.GetItemAsync(id, partitionKey);
if (item == null)
{
return NotFound();
}
return Json(item);
}
The item has data in the below format:
Javascript
function getStatus(inID, inPKey) {
var serviceURL = '/Item/Status';
var inData = { id: inID, partitionKey: inPKey }
$.ajax({
type: "GET",
url: serviceURL,
data: inData,
dataType: "json",
success: successFunc,
error: errorFunc
});
}
function successFunc(data, status) {
alert(data);
}
function errorFunc() {
alert('error');
}
For some reason I am getting the "data" as error. How do I get the data in a valid json format? Please help.