Skip to content Skip to sidebar Skip to footer

Return ActionResult To A Dialog. ASP.NET MVC

Given a method.. public ActionResult Method() { // program logic if(condition) { // external library // external library returns an ActionResult } return View(

Solution 1:

You can call Method() by just routing your jQuery .ajax() request to it. Since it's just returning straight up html, make sure you set your response type to expect that, and then your jQuery callback handler will have to deal with the resulting html. For example,

$("#myButton").click({
   $.ajax({
            // Basic ajax request properties
            url: /* route to call Method() */,
            data: {}
            dataType: "html",
            type: "GET",
            success: function(objResponse){
                   alert(objResponse);    // alerts the html of the result
                   /* Deal with response here, put the html in a dialog */
            }
      })
});

Post a Comment for "Return ActionResult To A Dialog. ASP.NET MVC"