c# - Ajax.BeginForm refreshing the whole page in MVC -


i've been trying add ajax functionality mvc site, however, run problem regarding page refreshing. i've created rss view on homepage sidebar, allows user select rss feed want view using drop down list. using html.begin form option in mvc, however, decided cool feature have rss feeder refresh, rather having whole page refresh. implemented ajax.begin form, whole page still refreshing.

here code inside view:

<div class="rss_feed">     <h3>rss feed</h3>      @using (ajax.beginform("index", "home",         new ajaxoptions         {             httpmethod = "post",             updatetargetid = "feedlist"         }))     {         @html.dropdownlistfor(x => x.selectedfeedoption, model.feedoptions)         <input type="submit" value="submit" />      }      <div id="feedlist">         @foreach (var feed in model.articles)         {             <div class="feed">                 <h3><a href="@feed.url">@feed.title</a></h3>                 <p>@feed.body</p>                 <p><i>posted @datetime.now.subtract(@feed.publishdate).hours hour ago</i></p>             </div>            }     </div> </div> 

when user selects feed type drop down menu, , clicks submit button, feed should update selected option.

in _layout view following bundle loaded:

@scripts.render("~/bundles/jquery") 

any great.

i use ajax call in jquery this

$('#selectedfeedoption').change(function() {     $.ajax({         url: "@(url.action("action", "controller"))",         type: "post",         cache: false,         async: true,         data: { data: $('#selectedfeedoption').val() },         success: function (result) {             $(".feedlist").html(result);         }    }); }); 

then put contents of feedlist div in partial view , on controller

public partialviewresult feedlist(string data){     model model = (get search result);     return partialview("_feedlist", model); } 

hopefully helps.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -