BramSnoek BramSnoek - 4 months ago 10x
Ajax Question

Success, failure not called Ajax call to C# function

I've been sitting on a problem and I can't figure out why the problem is even there.

The problem is that I'm calling C# function via Ajax post.

The javascript code is

type: "GET",
url: "Home/LogIn",
data: { userName: username, password: password },
dataType: 'json',
succes: function (data) {
alert(data.d + ' Succes')
failure: function (data) {
alert(data.d + ' failure');

And the C# function code is

public string LogIn(string userName, string password)
LogInController loginController = (LogInController)Session["LogInController"];

User tempuser = loginController.CheckLogin(password, userName);

if (tempuser != null)
massdrop = new MassdropShop(tempuser);
Session["LoggedInName"] = tempuser.Name;
Session["massdrop"] = massdrop;
return "1";
return "0";

When I run this code, it triggers the C# function, the C# function does it's job and everything's fine. But for some reason the Success and Failure function aren't running.

Is there anyone who could enlighten me to what I'm doing wrong?




Try success instead of succes. I've had the same issue

        succes: function (data) {
        alert(data.d + '  Succes')

should be

    success: function (data) {
        alert(data.d + '  Succes')

Hope this solves the problem, if not comment and I'll take a closer look at it!