Could someone please help me with a code snippet to understand how to call asmx web services from a backbone collection? The provided example is very simple.
Collection
window["Persons"] = Backbone.Collection.extend({
model: Person,
url: "service.asmx/GetPeople"
});
Note: I have the service.asmx file in place.
Asmx End point
[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;
}
The Model
public class Person
{
public string Name { get; set; }
public Person(string name)
{
Name = name;
}
}
When I execute the below code, Chrome XHR inspector shows an error:
var family = new Persons();family.fetch();
Request format is unrecognized for URL unexpectedly ending in '/GetPeople'