$.ajax({type: 'POST',url: '@Url.Action("PipeLogic", "Survey")',data: { listQuize },success: function (response) {window.location.href = urldata;if (response != null) {alert("Question Piped");}else {alert("Question Not Piped");}},error: function (response) {}});
Interviews5 answers
How we can achieve Ajax method call using MVC
5 Answers
Bidyasagar MishraPosted Jul 11, 2019, 7:32 PM EDT
$.ajax({
type: 'POST',
url: '@Url.Action("PipeLogic", "Survey")',
data: { listQuize },
success: function (response) {
window.location.href = urldata;
if (response != null) {
alert("Question Piped");
}
else {
alert("Question Not Piped");
}
},
error: function (response) {
}
});
Kalyani ShevalePosted Dec 26, 2018, 8:06 PM EST
Use a Razor to dynamically change your URL by calling your action like this:
$.ajax({
type: "POST",
url: '@Url.Action("ActionName", "ControllerName")',
contentType: "application/json; charset=utf-8",
data: { data: "yourdata" },
dataType: "json",
success: function(recData) { alert('Success'); },
error: function() { alert('A error'); }
});
Disha RavalPosted Jun 12, 2018, 7:16 PM EDT
Its first calling the FirstAjax action with default HttpGet request and renders the blank Html view . (Earlier you were not having it)
later on loading of DOM elements of that view your Ajax call get fired and displays alert.
Thanks!
Sankara Krishnan VenugopalPosted Apr 27, 2018, 10:16 PM EDT
A simple ajax call using mvc is,
@Ajax.ActionLink("Get User Details", "GetDetails", new AjaxOptions
{
UpdateTargetId = "divGetAllUsers",
HttpMethod = "GET",
OnSuccess = "fnSuccess",
})
Jaipal ReddyPosted Apr 3, 2018, 5:28 AM EDT


