$.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) {}});
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'); } });
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!
A simple ajax call using mvc is, @Ajax.ActionLink("Get User Details", "GetDetails", new AjaxOptions { UpdateTargetId = "divGetAllUsers", HttpMethod = "GET", OnSuccess = "fnSuccess", })