Still working through JQuery to get data and repopulate portions of a page. Right now I cannot get it to return data but it does pop an error saying “data is undefined”.
Code:
var retrieveData2 = function(path, productGroup, productType, itemsPerPage, pageIndex, filters, fnHandleCallback) {
$.getJSON(path
, { productGroup: productGroup, productType: productType, itemsPerPage: itemsPerPage, pageIndex: pageIndex, filter: filter }
, function(data) { fnHandleCallback(data); });
};
function updateNavIndex(pageIndex) {
var filters = $("form").serialize();
var productGroup = $("#valProductGroup").attr('title');
var productType = $("#valProductType").attr('title');
var itemsPerPage = $("#ItemsPerPage").val();
retrieveData2("/CatalogAjaxController/UpdateNavigation", productGroup, productType, itemsPerPage, pageIndex, filters, handleMenuData(data));
}
function handleMenuData(data) {
$("#CatalogPagingMenu").remove();
// [http://ejohn.org/blog/javascript-micro-templating/][apply data to template]
}
when the updateNavIndex function is called I get an error of “Microsoft JScript runtime error: ‘data’ is undefined”.
What am I missing?
ah! closer (the answer with 1 vote right now) – yet no server call is being made. It goes directly to the callback handler. 🙁
Got it working for the most part. My URL was pointing at CatalogAjaxController. It should point to CatalogAjax as MVC knows it is a controller.
Instead of:
I needed to do:
Because of my routes I ended up changing it to:
Notice the word “Controller” is not part of the path now. Kudos to the help on this. No exactly right answer but all answers gave me the meat to get through this. Special kudos to Ben Scheirman for some of his time today to show me around FireBug and using $.ajax with Partial Views!