I'm buildung a WebApplication in asp.net with c# and i have a problem to call a c# function from the JS.
My code is like this:
in js:
Function doStuff()
{
var service = new seatService.Service1();
service.DoWork(id, onSuccess, null, null);
}
and in the service page is:
[ServiceContract(Namespace = "seatService")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1
{
[OperationContract]
public static void DoWork(string id)
{
//here there is a function that calls the DB
}
}
The strange thing is that one of 20 times it actually works (with the same code) but most of the time it fails and I get the message:
uncaught referenceEror - seatService is not defined.
and the status code is 500 Internal Server Error.
Since it sometime working and sometime doesn't - where is my problem?
Functionin your JavaScript code should befunction(lowercase)