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

  • SEARCH
  • Home
  • 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 6106951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:08:05+00:00 2026-05-23T14:08:05+00:00

Right now I’m learning about MVC’s implementation of Ajax and I’m having trouble getting

  • 0

Right now I’m learning about MVC’s implementation of Ajax and I’m having trouble getting it to work correctly. Here’s what I have:

@Ajax.ActionLink("Click here to get a title", "Yo",
    new AjaxOptions { OnSuccess = "alert(\"YES!\")", OnFailure = "alert(\"WHY?!\")" })

And here are the two controller methods:

    public PartialViewResult GetThatTitle()
    {
        var titular = new TitleDataEntity { };
        titular.TitleName = "Inception!";
        titular.PublishDate = DateTime.Now;
        titular.Id = 2;

        return PartialView("_testView", titular);
    }

    public JsonResult Yo()
    {
        var titular = new TitleDataEntity { };
        titular.TitleName = "Inception!";
        titular.PublishDate = DateTime.Now;
        titular.Id = 2;
        if(Request.IsAjaxRequest())
        {
            return Json(titular);
        }
        return Json(titular);
    }

When I call the function “Yo”, the browser gives me the “WHY?!” alert box. But when I call GetThatTitle, it gives me the success alert. Why is it failing when I try and return a Json result?

  • 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-23T14:08:06+00:00Added an answer on May 23, 2026 at 2:08 pm

    You need to allow GET requests like this when returning JSON which are disabled by default:

    return Json(titular, JsonRequestBehavior.AllowGet);
    

    Also I would strongly recommend you using FireBug. It shows all AJAX requests in its console and you see the requests and responses. If you have used it you would have seen the following:

    InvalidOperationException: This
    request has been blocked because
    sensitive information could be
    disclosed to third party web sites
    when this is used in a GET request. To
    allow GET requests, set
    JsonRequestBehavior to AllowGet.]

    which would have put you on the right track of course.

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

Sidebar

Related Questions

Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as
Right now I'm working on my project and I have a question about initialization
Right now I have this SQL query which is valid but always times out:
Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
Right now, I have three models Post, Comment and User (using Devise ) associated
Right now, I have a domain entity named StyleBundle. This StyleBundle takes a list
right now i have this <script type='text/javascript'> $(#beau).click(function(){ $(#beau).animate({margin-Top: 738px}, fast); }); </script> and
Right now any new UIViewController added to my storyboard needs to have a class
Right now I have some TabItems in my App which are implicitly styled. I

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.