ASP.NET MVC Page not Updated when using AJAX ASP.NET MVC Page not Updated when using AJAX ajax ajax

ASP.NET MVC Page not Updated when using AJAX


You need to put the content of the returned partial view somewhere on the page

<div id="big-posts">   <span id="insertnewpostbelow"></span>   <div id="newPost"></div></div>

On the call back function try:

function postingSucceeded(data) {    $("#newPost").html(data);}

Hope this helps!


This is because you have an Ajax form in _Posts PartialView. After the placement, say, after <span id="insertnewpostbelow"></span> you need to run jquery.unobtrusive-ajax on page again.

Note that the scripts will render on page loads, not after any changes in page (like updates by PartialView).

Solution: call the script again, after the page update :)


First thing you don't need to have parenthesis

OnSuccess = "postingSucceeded()"                            ^^^OnFailure = "postingFailed()"                         ^^^

just

OnSuccess = "postingSucceeded",OnFailure = "postingFailed"

and now HTML code

<div id="big-posts">   <span id="insertnewpostbelow"></span>   <div id="AppendPostsHere"></div></div>

and javascript code out side the $(document).ready(....)

function postingSucceeded(newPosts) {    $("#AppendPostsHere").html(newPosts);}

hope this willl work!