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 6991735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:32:32+00:00 2026-05-27T19:32:32+00:00

Here is my AJAX call: $(document).ready(function () { $(#btnSignup).click(function () { $.ajax({ type: POST,

  • 0

Here is my AJAX call:

        $(document).ready(function () {
        $("#btnSignup").click(function () {
            $.ajax({
                type: "POST",
                dataType: 'json',
                url: "/Newsletter/Signup",
                data: $('#signupForm').serialize(),
                success: function (response) {
                    if (response.Success) {
                        $('#signupMessage').show(0);
                    }
                    else {
                        showValidationErrors(response.Data);
                    }
                }
            });
            return false;
        });

Here is my controller:

    [HttpPost]
    public JsonResult Signup(FormCollection values)
    {
        var newsletterSubscriber = new newsletterSubscriber();
        TryUpdateModel(newsletterSubscriber);

        try
        {               
            newsletterSubscriber.newslettersubscriber_firstname = values["firstName"];
            newsletterSubscriber.newslettersubscriber_lastname = values["lastName"];
            newsletterSubscriber.newslettersubscriber_email = values["emailAddress"];    

            //Save Subscriber
            wildlifeDB.AddTonewsletterSubscribers(newsletterSubscriber);
            wildlifeDB.SaveChanges();

            //return RedirectToAction("Index");
            return Json(new { result = "success" });

        }
        catch
        {
            //Invalid - redisplay with errors
            //return View("Index");
            return Json(new { result = "failure" });

        }
    }

Why is it that my AJAX call’s conditional “if (response.Sucess)” is never satisfied. I can see that the data is making it into the database?

  • 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-27T19:32:33+00:00Added an answer on May 27, 2026 at 7:32 pm

    You’re returning a JSON object that looks like this: { result: "success" }, but in your client code you’re checking for a property called Success. This doesn’t work because the object that’s returned doesn’t contain a property called Success.

    Your code should check for if (response.result === 'success') instead. That should work.

    To make the check prettier, I generally return an object that looks like { success: true }. In this case, the code can be written as if (response.success), which is a lot easier on the eyes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here is my code: $(document).ready( function() { $('#form').bind('change', function(){ $.ajax({ type: 'get', url:
I have the following jQuery script: $(document).ready(function() { $.ajax({ url: 'temp.ajax.php', type: 'GET', success:
I have the below jQuery code: $(document).ready(function () { $('#ajaxButton').click(function () { $.ajax({ url:
Here's my javascript: <script type=text/javascript> var timer; $(document).ready(function () { timer = setInterval(updatetimerdisplay, 1000);
Here's an example taken from http://docs.jquery.com/API/1.1/AJAX#.24.post.28_url.2C_params.2C_callback_.29 $.ajax({ type: POST, url: some.php, data: name=John&location=Boston, success:
I am using jquery 1.3.2 and have the following code, $(document).ready(function () { $.ajax({
jQuery(document).ready(function(){ // ok im geting the value here maybe i should make it in
I am doing an AJAX call that returns some HTML and jQuery: <div id='selected'>Here
I am getting an error in an ajax call from jQuery. Here is my
How to get array data from json in c#? Here is the ajax code

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.