I’have a dialog box in JQuery that have two buttons. When the button “Upload Anyway” is clicked I call an Action of my Controller.
$(function () {
$(“#dialog:ui-dialog”).dialog(“destroy”);
$("#dialog-confirm").dialog({
resizable: false,
height: 300,
width: 500,
modal: true,
buttons: {
"Upload Anyway": function () {
$(this).dialog("close");
var month = '@ViewBag.duplicateString' ;
var path = $("#path").val();
$.getJSON('@Url.Action("UpdateComp")', { dateToUpdate: month, filePath: path },
function() {});
},
Cancel: function () {
$(this).dialog("close");
}
}
});
In the Controller I just want to process the data and return a view.
public ActionResult UpdateComp (string dateToUpdate, string filePath)
{
//Process Data
return View(compList.Values.AsEnumerable<CompUser>());
}
When I click over the “Upload Anyway” I’m correctly redirected to the Action (I’ve checked with debug), but the view is not loaded. I’m not very good at JQuery so maybe I’m doing something wrong.
Thanks for your help!
Changing the $.getJSON by $.get and display the resulted view in my main div solve the problem.
Note that I render a partial view in order to display the div correctly.
Here is the JQuery code, hope that will help some other person.