skip to Main Content

Ajax Post in Asp.net Core in .Net 6 is not working in Action method – Jquery ajax

I am making an ajax call in cshtml like below: $(document).ready(function(){ $('.dl-dir-list').click(function(e){ console.log($(e.target).data('path')); console.log(JSON.stringify({path: $(e.target).data('path')})); $.ajax({ type: "POST", url: '@Url.Action("GetFiles")', data: JSON.stringify({path: $(e.target).data('path')}), dataType: "json", contentType: "application/json; charset=utf-8", success: function (response) { console.log(response); }, error: function () { alert("Error while…

VIEW QUESTION

Can not pass parameters from JQuery AJAX to controller

I am calling a method in JQuery like this var data = { 'minAge': minAge, 'MaxAge': maxAge, 'ProductType': ProductType, 'ProductSubject': ProductSubject, 'ordering': '@Ordering.NotOrder', 'Searchkey': "", 'CatId': @Context.Request.Query["CatId"] } $.ajax({ contentType: 'application/x-www-form-urlencoded', dataType: 'json', type: "POST", url: '/ApplyFilter', data: data, success:…

VIEW QUESTION
Back To Top
Search