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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:27:26+00:00 2026-06-06T08:27:26+00:00

When the Action method below attempts to return the Json result no data object

  • 0

When the Action method below attempts to return the Json result no data object comes back to the $.ajax function. Hence I presume I am not serializing the arrays prior to sending them off as a Json result. I need to retain the array names i.e: ProgTypes, Ages etc. So I know which array is which when the data returns from the server.

   $.ajax({
            url: '/Education/FilterLists',
            dataType: 'json',
            data: { svalues: svalues, firsttype: $firsttype },
            traditional: true,
            success: function (data) {

              //do something with data

                alert('done');
            }
        });

..

      public JsonResult FilterLists(int[] svalues, string firsttype)
        {

 //Some logic takes place and below arrays are produced

            int[] ProgTypes = programs.Select(x => x.FilterValToCatMaps.FirstOrDefault(c => c.FilterValue.FilterID == 5).FilterValueID).Distinct().ToArray();

            int[] Ages = programs.Select(x => x.FilterValToCatMaps.FirstOrDefault(c => c.FilterValue.FilterID == 4).FilterValueID).Distinct().ToArray();

            int[] Countries = programs.Select(x => x.ParentCategory.ParentCategory.ParentCategory.CatID).Distinct().ToArray();


            return Json(new { progtypes = ProgTypes, ages = Ages, countries = Countries});

        }
  • 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-06-06T08:27:27+00:00Added an answer on June 6, 2026 at 8:27 am

    You are attempting to retrieve JSON data via a GET request (jQuery AJAX implicitly does a GET unless you specify the “type: ‘POST'” option”). ASP.NET blocks JSON returning GETs for security reasons with an exception of this message:

    “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.”

    Your success function is never getting executed because the request isn’t a success. I would recommend getting FireBug for FireFox and using the ‘Net’ tab or use chromes built in debugger and use the ‘Network’ tab if you are going to be doing any web development (especially AJAX). Network errors pop right up in there and it can save you a lot of time.

    You have two options at this point, change your .NET code or change your JavaScript, pick one below:

    $.ajax({
        url: '/Education/FilterLists',
        dataType: 'json',
        type: 'POST', //ADD POST HERE
        data: { svalues: svalues, firsttype: $firsttype },
        traditional: true,
        success: function (data) {
    
          //do something with data
    
            alert('done');
        }
    });
    

    OR

    return Json(new { progtypes = ProgTypes, ages = Ages, countries = Countries}, JsonRequestBehavior.AllowGet);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Action Method that I'd either like to return JSON from on
I'm sending a JSON object to an action method. Everything works client side and
In the code below I pass method B as an action to be perfomed
In the method CreateView() (check my View Engine below) or in my custom action
I have an action method that depending on some conditions needs to return a
I am using Url.Action() method to load view, Since heavy data is been accessed
I have a MVC action method from which I am returning the data as
Below is the action method that returns images from the database as they are,
Hi I am having difficulties using Url.Action method, please see my code below, what
I am trying to post data to the action method in the postData section

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.