asp.net mvc 4 - Load Different partial views on radio button click -


i trying load different partial views in single div depending on radio button selection. when user clicks on individual button partial view should appear, if click on business business partial view should appear

my view page code

<script type="text/javascript">     $(function () {         $("[name=regesterhere]").on('change', function () {             var $radio = $(this);              $.ajax({                 url: '@url.action("getregisterform", "home")',                 data: regesterhere = $radio.val(),                 type: 'get',                 success: function (data) {                     $("#loadpartial").html(data);                 }             });         });     }); </script>  <h2>getregisterform</h2> <table>      <tr>         <td colspan="1">@html.labelfor(m => m.regesterhere)</td>         <td colspan="2">@html.radiobuttonfor(m => m.regesterhere, "individual") individual                           @html.radiobuttonfor(m => m.regesterhere, "business") business</td>     </tr> </table>  <div id="loadpartial"> </div> 

and controller code is

[httpget]         public actionresult getregisterform(string regesterhere)         {             if (regesterhere == "individual")             {                 return partialview("individualpartialviewname");             }             else             {                 return partialview("businesspartialviewname");             }          } 

when running code, second partial view directly appearing. please me ever radio button clicked corresponding partial view should loaded

it appears may not getting radio button value that's checked. may want try checked radio button value:

var value = $("input[name='regesterhere']:checked").val(); 

and use in ajax call:

data: regesterhere = value, 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -