我有一个端点GET使用asp.net web api和一些搜索
ASP.NET WEB API
public IEnumerable<AudtisDTO> Get(searchCriteriaObject value)
{
return _auditService.getSearchResults(value);
}
Backbone.js的
//集合
var AuditsCollection = Backbone.Collection.extend({
model: Audit,
url: 'http://localhost:56501/api/searchaudits',
sync: function (method, model, options) {
if (options.crossDomain == undefined) {
options.crossDomain = true;
}
if (!options.xhrFields) {
options.xhrFields = { withCredentials: true };
}
//options.timeout = 1000;
alert(method + ": " + JSON.stringify(model));
return Backbone.sync(method, model, options);
},
parse: function (data) {
console.log(data);
}
});
//型号
var Audit = Backbone.Model.extend({ });
//查看
var ListAuditsView = Backbone.View.extend({
formdata = [{"searchField1":"1","searchField2":"2"}]
var _audit = new Audit(formData);
this.collection.add(_audit);
this.collection.fetch();
});
当我这样做时,我得不到任何回报。它成功通话但没有返回任何内容。我看到提琴手看到即将发生的事情并且显示为空。我猜是因为我没有正确地将参数发送到端点。
感谢您的帮助