开发者

How to get value from MVC controller action on page asynchronously

开发者 https://www.devze.com 2023-03-15 15:40 出处:网络
I have a page with cascad downloaded areas (select something in first area -> downloaded specific data to second area).

I have a page with cascad downloaded areas (select something in first area -> downloaded specific data to second area).

And I need to hide some content depending on data from the first area.

I need something like this (in javascrip开发者_StackOverflowt):

var result = getDataFromController(controllerName:"Quotes", 
                                   actionName:"IsQuoteOrdered",
                                   param: quoteId);


Consider using jquery to simplify the ajax calls.

If you go that route the following would allow you to replace the dd2 element portion of the page with the result of a controller action call upon change of selection in dd1 :

$(document).ready(function() {
  $('#dd1').change(function() {
        $.ajax({
            type: "POST",
            cache: false,
            data: 'firstDropdownSelectedValue=' + $('#dd1').val(),
            url: 'YourControllerName/YourActionName',
            success: function (data) {
              $('#dynamicDivPortionOfThePageReturnedByYourView').replaceWith(data);
            }
        });
  });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消