[英]How to call asmx webservice for collection using BackboneJs
I hope someone could put me through a code to learn to call asmx webservices from backbone collection. 我希望有人可以让我通过一个代码来学习从骨干集合中调用asmx webservices。 The example i have put here is extremely simple 我放在这里的例子非常简单
window["Persons"] = Backbone.Collection.extend({
model: Person,
url: "service.asmx/GetPeople"
});
note: I do have a service.asmx file at the point 注意:我确实有一个service.asmx文件
[WebMethod]
[ScriptMethod]
public static List<Person> GetPeople()
{
List<Person> people = new List<Person>(10);
for (int i = 0; i < 10; i++)
{
people.Add(new Person(i.ToString()));
}
return people;
}
public class Person
{
public string Name { get; set; }
public Person(string name)
{
Name = name;
}
}
when i do the below chrome xhr inspector informs me of this error 当我这样做时,下面的铬xhr检查员告诉我这个错误
var family = new Persons();family.fetch();
Request format is unrecognized for URL unexpectedly ending in '/GetPeople' 对于意外以'/ GetPeople'结尾的URL无法识别请求格式
You will want to override the Backbone.sync() function to customize the persistence and retrieval of models from the server. 您将希望覆盖Backbone.sync()函数以自定义服务器中模型的持久性和检索。
You can take a look at the annotated source code of how the Backbone.sync() function is overwritten for a local storage alternative. 您可以查看有关如何为本地存储替代方法覆盖Backbone.sync()函数的带注释的源代码 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.