I have a simple ApiController I'm testing:
namespace SMOnline.Controllers
{
public class DocumentosController : ApiController
{
Documentos[] docs = new Documentos[]
{
new Documentos { ID = 1, Tipo = 1, Designacao = "FC001"},
new Documentos { ID = 2, Tipo = 1, Designacao = "FC002"}
};
public IEnumerable<Documentos> GetAll()
{
return docs;
}
}
}
And on the client side i'm calling this from a different domain
$.ajax({
async: true,
type: 'GET', //GET or POST or PUT or DELETE verb
url: apiUrl + 'Documentos/', // Location of the service
dataType: 'jsonp', //Expected data format from server
})
.done(function (data) {
// On success, 'data' contains a list of documents.
$.each(data, function (key, item) {
alert(item.Designacao);
})
})
.fail(function (jqxhr, textStatus, error) {
alert(textStatus + " " + error);
});
My problem is that the JSONP request is allways returning me an error
parsererror Error: jQuery20301899278084596997_1380125445432 was not called
I've been searching arround but still haven't found a solution for this.
EDIT: I forgot to mention that using fiddler the returned values seem correct header is 200 and the content is a JSON array.