@model WebApplication14.Domain.Concrete.ViewCurrentDisciples @{ ViewBag.Title = "Test"; } <html> @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/ajax") <body> <div id="Results_Section">@{Html.RenderAction("FirstSpisok", "Test");}</div> <div class="col-md-6 .col-md-offset-3"> <button class="btn btn-primary" onclick="PostData()">Отправить</button> </div> <script type="text/javascript"> $(document).ready(function () { if($('div[class = "col-md-4"]').is(":hidden")) { $('div[class = "col-md-4"]').slideDown(2000); } }); function PostData() { var params = new Array(); var napr = new Array(); var testdata = { 'Params': params, 'Napr': napr } $('input[class = "checking"]:checked').each(function () { params.push($(this).val()); napr.push($(this).attr('id')); }) $.ajax({ type: "POST", url: '/Test/FirstSpisok', data: JSON.stringify(testdata), contentType: "application/json; charset=utf-8", dataType: "json", success: successFunc, async : true } ); //$('div[class = "col-md-4"]').slideUp(2000); function successFunc(data) { console.log("sdfsdf" + data); $("#Results_Section").append(data); } } function errorFunc(errorData) { alert('Ошибка' + errorData.responseText); } let a = function(spec, value) { } </script> </body> </html> Controller
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using WebApplication14.Models.DataBaseModel; using WebApplication14.Domain.Concrete; using WebApplication14.Domain.Abstract; namespace WebApplication14.Controllers { public class TestController : Controller { public PartialViewResult FirstSpisok() { return PartialView(new ViewCurrentDisciples { sp = (SpecConstructor)Session["Cart"] }); } [HttpPost] public JsonResult FirstSpisok(ModelOfOutPut mf) { return Json(new ViewCurrentDisciples { sp = (SpecConstructor)Session["Cart"] }); } } }
$("Results_Section").append();because invalid selector (must be either #Result_section or .Result_section) and does not add anything as a parameter to the append function (assuming that there will be data from the responce) - alexoander