Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:14:49+00:00 2026-05-25T10:14:49+00:00

i’ve been trying to login through AJAX but somehow its not working. my controller

  • 0

i’ve been trying to login through AJAX but somehow its not working.

my controller action is

       public string CheckLogin(Users checkuser)
       {
            if (db.CheckUserLoginDetails(checkuser.Email, checkuser.Password))
            {
                return "Login Successful:" + checkuser.Email;
            }
            else
            {
                return "Login UnSuccessful";
            }
        }

my View AJAX code is

        $(':submit').click(function (e) {
        var username = $('#username').val();
        var password = $('#password').val();
        var postdata =
        {
            'Email': username,
            'Password': password
        };
        $.post({
            url: 'http://localhost:7651/Home/CheckLogin',
            data: postdata,
            success: function (msg) {
                $('#Result').html(msg);
            }
        });
    });

i don’t know whats wrong in the code ..but some how its not making a call to controller action at all…

  1. yes i am runing on localhost
  2. CheckLogin action is i Home Controller
  3. Routes are defualt…
  4. will try to have a look on net panel.. dont have any idea on that
  5. USERs Model

        [Key]
        public virtual int UserID { get; set; }
    
        [Required(ErrorMessage="Required")]
        public virtual string FirstName { get; set; }
    
        [Required(ErrorMessage = "Required")]
        public virtual string LastName { get; set; }
    
        [Required(ErrorMessage = "Required")]
        [DataType(DataType.EmailAddress)]
        public virtual string Email { get; set; }
    
        [Required(ErrorMessage = "Required")]
        [DataType(DataType.Password)]
        public virtual string Password { get; set; }
    
        [DataType(DataType.Date)]
        public virtual DateTime JoiningDate { get; set; }
    
  6. i have tried the breakpoints but the calls are not going and breakpoints are never hitting…

  7. Result DIV exits in DOM .. in index view/ in HTML.BeginForm()
  8. dont know how to add error to $.AJAX

Thanks for all the checklist though…. please help

here is the view …

@model Temp1.Models.Users

@{
    ViewBag.Title = "Index";
}

<script src="@Url.Content("~/Scripts/jquery-1.5.1.js") type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.5.1-vsdoc.js") type="text/javascript"></script>


<h2>Login</h2>

@using (Html.BeginForm("CheckLogin", "Home"))
{ 
    @*<p>
        <input type="text" id="username" value="" />
    </p>

    <p>
        <input type="password" id="password" value="" />
    </p>
    *@

    @Html.TextBoxFor(model => model.Email)
    @Html.PasswordFor(model => model.Password)

    <p>
        <input type="button" value="Login" id="btnLogin" />
    </p>


    <div id="Result">

    </div>


}


<script type="text/javascript">

    $('#btnLogin').click(function (e) {
        var postdata =
        {
            "Email": "temp@temp.com",
            "Password": "temp123"
        };

        $.ajax({
            url: '@Url.Action("CheckLogin","Home")',
            data: postdata,
            success: function (msg) {
                $('#Result').html(msg);
            },
            error: function (data) {
                $('#Result').html(msg);
            }

        });

    });

</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:14:50+00:00Added an answer on May 25, 2026 at 10:14 am

    Your ajax submit url should be like this ‘/controler/action’. The best practice is to use Url.Action("actionName","ControlerName") if not you will have to change your jQuery when you deploy somewhere else.

     $.post({
            url: '@Url.Action("CheckLogin","Home")'
            data: postdata,
            success: function (msg) {
                $('#Result').html(msg);
            }
        });
    

    if doing this only not working, try changing your action like this,

     public string CheckLogin( string Email, string Password){
    
    }
    

    and change your postData,

     var postdata =
        {
            Email: username,
            Password: password
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.