I am using the following to talk to a web api endpoint controller. The problem I am having is that it returns xml instead of json. From what I understand you need to pass the content type like below to determine the return type, that is why I have it set to JSON. I am stumped as to how to return json.
$.ajax({
url: 'http://localhost:43043/api/main?ordernumber=33232048&category=damage',
type: 'GET',
contentType: "application/json; charset=utf-8",
//data: {
// orderNumber: num,
// category: cat
//},
success:
function (data) {
var usingRoutData = document.URL;
ko.applyBindings(new InvoiceViewModel(data));
},
error: function () {
alert('failure');
}
});
dataType:"json"as one of the options for the .ajax call, and of course make sure the server is outputting valid json code.