I am encountering an issue with passing updated data from my controller to the view after making an Ajax call. Here is a simplified version of what I am trying to achieve:
Javascript
$ANALYZE = $('#submitID');
$ANALYZE.click(function () {
var objectID = document.getElementById('objectIDInput').value;
$.ajax({
url: '@Url.Action("AnalyzeData")',
type: "POST",
dataType: "json",
data: { 'objectID': objectID },
success: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
});
Controller
public ActionResult Index(AnalyzeViewModel data)
{
//Logic to update view model
}
[HttpPost]
public ActionResult AnalyzeData (int objectID)
{
//Logic to analyze data and update view model, then return JSON response
}
View
<tbody class="scrollContent">
@if (Model.fileData != null)
{
//Display data in table
}
</tbody>