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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:22:02+00:00 2026-05-11T17:22:02+00:00

I have the following JQuery code: // When the document is ready, start firing

  • 0

I have the following JQuery code:

// When the document is ready, start firing our AJAX
$(document).ready(function() {
    function showValues() {
        var str = $("form").serialize();
        $("#results").text(str);
    }

    $(":checkbox, :radio").click(showValues);
    $("select").change(showValues);
    //showValues();

    // Bind actions...
    $("#navIndex a").bind("click", function(e) { updateNavIndex($(this).attr('href')); });
    $("#navPrevNext a").bind("click", function(e) { updateNavPrevNext($(this).attr('href')); });
    $("#ItemsPerPage").bind("change", function(e) { updateAll(); });
    $(":checkbox, :radio").bind("change", function(e) { updateAll(); });

    $("#navIndex a").click(function() {
        // switch class type...
        $("#navIndex a").removeClass('selected');
        $("#navIndex span").removeClass('selected');
        $("#navIndex a").addClass('notselected');
        $("#navIndex span").addClass('notselected');
        $(this).removeClass('notselected');
        $(this).addClass('selected');
        $(this).parent().removeClass('notselected');
        $(this).parent().addClass('selected');

        // Get navigation index...
        var navIndex = $(this).attr('href');

        this.blur();
        return true;
    });
    $("#navPrevNext a").click(function() {
        // Get navigation index...
        var navIndex = $(this).attr('href');

        this.blur();
        return true;
    });
});

// Use the getJSON method to call our JsonResult action
var retrieveProductData = function(path, productGroup, productType, itemsPerPage, pageIndex, filter, fnHandleCallback) {
    $.getJSON(path
             , { productGroup: productGroup }
             , { productType: productType }
             , { itemsPerPage: itemsPerPage }
             , { pageIndex: pageIndex }
             , { filter: filter }
             , function(data) { fnHandleCallback(data); });
};

// Use the getJSON method to call our JsonResult action
var retrieveMenuData = function(path, productGroup, productType, itemsPerPage, pageIndex, filter, fnHandleCallback) {
    $.getJSON(path
             , { productGroup: productGroup }
             , { productType: productType }
             , { itemsPerPage: itemsPerPage }
             , { pageIndex: pageIndex }
             , { filter: filter }
             , function(data) { fnHandleCallback(data); });
};

// The path parameter is our JSON controller action
function updateNavIndex(pageIndex) {
    var filters = $("form").serialize();
    var productGroup = $("#valProductGroup").attr('title');
    var productType = $("#valProductType").attr('title');
    var itemsPerPage = $("#ItemsPerPage").val();

    retrieveMenuData("/CatalogAjaxController/UpdateNavigation"
                    , productGroup
                    , productType
                    , itemsPerPage
                    , pageIndex
                    , filters
                    , handleMenuData);
    retrieveProductData("/CatalogAjaxController/UpdateNavigation"
                       , productGroup
                       , productType
                       , itemsPerPage
                       , pageIndex
                       , filters
                       , handleProductData);
}

// The path parameter is our JSON controller action
function updateNavPrevNext(pageIndex) {
    var filters = $("form").serialize();
    var productGroup = $("#valProductGroup").attr('title');
    var productType = $("#valProductType").attr('title');
    var itemsPerPage = $("#ItemsPerPage").val();

    retrieveMenuData("/CatalogAjaxController/UpdateNavigation"
                    , productGroup
                    , productType
                    , itemsPerPage
                    , pageIndex
                    , filters
                    , handleMenuData);
    retrieveProductData("/CatalogAjaxController/UpdateNavigation"
                       , productGroup
                       , productType
                       , itemsPerPage
                       , pageIndex
                       , filters
                       , handleProductData);
}

// The path parameter is our JSON controller action
function updateAll() {
    var filters = $("form").serialize();
    var productGroup = $("#valProductGroup").attr('title');
    var productType = $("#valProductType").attr('title');
    var itemsPerPage = $("#ItemsPerPage").val();

    retrieveMenuData("/CatalogAjaxController/UpdateNavigation"
                    , productGroup
                    , productType
                    , itemsPerPage
                    , pageIndex
                    , filters
                    , handleMenuData);
    retrieveProductData("/CatalogAjaxController/UpdateProducts"
                       , productGroup
                       , productType
                       , itemsPerPage
                       , pageIndex
                       , filters
                       , handleProductData);
}

// Ok, now we have the JSON data, we need to do something with it.  I'm adding it to another dropdown.  
function handleMenuData(data) {
    $("#otherDropDownId > option").remove();
    for (d in data) {
        var item = data[d];
        $("#otherDropDownId").append("<option value=\"" + item.Value + "\">" + item.Text + "</option>");
    }
}

// Ok, now we have the JSON data, we need to do something with it.  I'm adding it to another dropdown.  
function handleProductData(data) {
    $("#otherDropDownId > option").remove();
    for (d in data) {
        var item = data[d];
        $("#otherDropDownId").append("<option value=\"" + item.Value + "\">" + item.Text + "</option>");
    }
}

My Controller looks like:

public class CatalogAjaxController : Controller
{
    [Authorize, AcceptVerbs(HttpVerbs.Post)]
    public JsonResult UpdateNavigation(string productGroup, string productType, int itemsPerPage, string pageIndex, string filters)
    {
        int pIndex = Convert.ToInt32(pageIndex.Remove(0, 1));

        ProductCatalogBrowserModel myModel;
        myModel = new ProductCatalogBrowserModel(productGroup, productType, pIndex, itemsPerPage);

        return new JsonResult() { Data = myModel.ProductDetailMenu.ToArray() };
    }

    [Authorize, AcceptVerbs(HttpVerbs.Post)]
    public JsonResult UpdateProducts(string productGroup, string productType, int itemsPerPage, string pageIndex, string filters)
    {
        int pIndex = Convert.ToInt32(pageIndex.Remove(0, 1));

        ProductCatalogBrowserModel myModel;
        myModel = new ProductCatalogBrowserModel(productGroup, productType, pIndex, itemsPerPage);

        return new JsonResult() { Data = myModel.ProductDetail.ToArray() };
    }

}

I can catch a break point in any of the 3 Update functions in the JS scripts but it does not drop into the Controller at all. Am I missing something?

  • 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-11T17:22:02+00:00Added an answer on May 11, 2026 at 5:22 pm

    I think you’re missing how your Ajax arguments need to be structured.

    $.getJSON(
        url,
        {
            'dataVal1': data1,
            'dataVal2': data2
        },
        myCallBackHandler
    );
    

    But, this passes a GET request, and chances are that you’ll need a POST.

    You can do this with a basic Ajax call:

    $.ajax({
        url: thePath,
        type: 'POST',
        data: {
            dataVal1: data1,
            dataVal2: data2
        },
        success: successHandler,
        failure: failureHandler
    });
    

    You can find greater usage scenarios here:

    http://docs.jquery.com/Ajax/jQuery.ajax#options

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer List<T> has no notification support. You could look at BindingList<T>,… May 11, 2026 at 11:59 pm
  • Editorial Team
    Editorial Team added an answer I think you have to do this in two steps:… May 11, 2026 at 11:59 pm
  • Editorial Team
    Editorial Team added an answer This is because when you do this in VB6: Dim… May 11, 2026 at 11:59 pm

Related Questions

I have the following script in my homepage $(function () { // same as
I have the following form in cakephp: <div class=quickcontactDisplay> <?php echo $form->create('Enquiry',array('action'=>'add','class'=>'quickcontact')); echo $form->hidden('visitor_id',
I'm trying to use jQuery.post() function to retrieve some data. But i get no
I'm having some issues with some jQuery code, and I'm hoping and thinking that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.