yad4u AJAX with Jquery in ASP.MVC2

AJAX with Jquery in ASP.MVC2

I'd like to get something via Ajax and put it into

What i have to return from Controler Action to put this into that DIV? Right now i had standard ASP.MVC view as result...

public ActrionResult MyAction() {    return View(); } 

and in javascript i have:

$.get(<url to controler action>, null, function(data) { $(#result).html(data); }) 

Typical action associated with MyAction, with reload page works perfect. but when i do $.get(...) i got whole page in "data" (content and master page). How can i get only part of View(), without MsterPage??

Returning JSON data to view page in ASP.NET MVC


Adding Include Files to the Add Controller T4 Templates in ASP.NET MVC
You could return a partial:. is there a way to programatically set a filter in jquery jqgrid?
public ActrionResult MyAction()  {    return PartialView(); } 
Where you have MyAction.ascx partial containing any HTML fragment:. Asp.net MVC utilising WCF
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <div>Hello</div> 
And you inject this partial using an AJAX call into the #result div:. Which strategy to choose for building web based business application
ASP.NET MVC output cache with dynamic fragmentRedirect site from www.a.com to a.com in asp.net mvc


Jquery thickbox to work with Url.Action link in Asp.net mvc
You'll want to use .
public ActrionResult MyAction() {     var stuff = new { id = 1, name = "test" }; //or whatever stuff you need in your page     return Json(stuff); } 
from your ActionResult method. .


As an alternative to a json response, you must return the html. All you need to did is to filter and receive the html this you want to append from the 'data' variable..
$.receive (<url to controler action>, null, function(data) {                $('#result').html($(data).find('#partOfViewID').html());                }); 


that's not a problem with jquery / ajax. you need an action this returns a partial view. not one this returns a view with a master page. . you must use this part:.
$.receive (, null, function(data) { $(#result).html(data); }).
although your action will have to have a partial view associated with it, not a regular view with a master page.. so make a new action. add a view to it, check the partial view checkbox. and put whatever you want to be reloaded in this partial view. .

96 out of 100 based on 71 user ratings 806 reviews