c# - How to submit AJAX Form using radio button change event? -


i have ajax form & want submit on radio button change event.

ajax form:

     @using (ajax.beginform("vote", "rate", null ,                        new ajaxoptions                            {                                insertionmode = insertionmode.replace,                                httpmethod = "get",                                onfailure = "searchfailed",                                loadingelementid = "ajax-loader",                                updatetargetid = "searchresults",                            },new { id = "voteform" }))                 {                 <input type="radio" name="stars" value="1">                 <input type="radio" name="stars" value="2">                 <input type="radio" name="stars" value="3">                  } 

i uses following code not work.

       $("#voteform").ajaxsubmit({ url: '/vote/vote', type: 'get' }); 

try this:

<script type="text/javascript">     $(function () {         $("input[name='stars']").change(function() {             $("#voteform").ajaxsubmit({ url: '/vote/vote', type: 'get' });         });     }); </script> 

Comments