c# - How to call Html.RenderAction() with parameters declarated in jscript? -
i have javascript in *.cshtml file
$(function () { sliderdiv.slider({ range: true, min: minval, max: maxval, values: [minval, maxval] }); sliderdiv.bind("slidechange", function (event, ui) { var d = "min=" + ui.values[0] + "&max=" + ui.values[1]; $.ajax({ type: "post", url: '@url.action("update", "default")', data: d, success: function (result, ajaxobj) { alert('ok'); alert(result.min + " - " + result.max); $("#ajaxresult").html('@{html.renderaction("update", "default");}'); }, error: function (ajaxobj, message, exceptionobj) { alert('no'); } }); }); } and controller:
public actionresult update(int? min, int? max) { if(min == null) min = 1; if(max == null) max = 1; var s = new slidermodel() { min = (int)min * 1000, max = (int)max * 1000 }; return new jsonresult { data = s, contentencoding = encoding.utf8, jsonrequestbehavior = jsonrequestbehavior.allowget, contenttype = "json" }; } i want use line
$("#ajaxresult").html('@{html.renderaction("update", "default");}'); to send ui.values[0] , ui.values[1] min , max parameters html.renderaction("update", "default")
something $("#ajaxresult").html('@{html.renderaction("update", "default", new {min = ui.values[0], max = ui.values[1]});}');
how can that???
var url = '@url.action("update", "default")'; url += '/?min=' + ui.values[0] + '&max=' + ui.values[1]; $("#ajaxresult").load(url); description: load data server , place returned html matched element.
Comments
Post a Comment