url routing - Javascript url content with parameter? -


i wish pass 'selectlang' parameter in javascript , redirect mvc controller var 'selectlang' have error , mention not exist in current content? please guide me thanks!

my javascript:

 $('.filterlang').on("click", function () {             var selectlang = document.getelementbyid("language").value;             location.href = '@url.content("~/surv_main/surv_main_details/?key=" + model.survey_key +"&language=" + selectlang)';          }); 

filterlang button class , "language" dropdownlist id.

have tried this:

$(document).on(".filterlang", "click", function(){    var selectedlang = $("#language").val(); // if normal dropdown, work both cases    var selected2lang = $("#language").select2("val"); // if select2 dropdown    window.location = '@url.content("~/surv_main/surv_main_details/?key=" + model.survey_key +"&language=' + selectlang + '")'; }); 

hope helps.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -