I have Api Controller
public class JsonController : Controller
{
private readonly IRepositor _repositor;
public JsonController(IRepositor repositor)
{
_repositor = repositor;
}
// GET: api/Json
[HttpGet]
public string Get()
{
return Repositions.StrocTable;
}
// POST: api/Json
[HttpPost]
public void Post([FromBody]List<Json> jsons)
{
_repositor.DataSetTwo(jsons);
}
}
and class
public class Repositions : IRepositor
{
public static string StrocTable { get; set; }
public void DataSetTwo(List<Json> cheked)
{
for (int i = 0; i < cheked.Count && cheked[i].Name == "Check"; i++)
StrocTable += cheked[i].Value;
}
}
so I wanna execute this script
$.ajax({
type: 'POST',
url: '/api/Json',
data: JSON.stringify(jsons),
contentType: 'application/json'
}).done($(hash).empty();
$.get('/api/Json').done(function (Stroctable) {
$('#Tables').append(Stroctable);
}););
i was got empty string after when i execute second times I've get string that should have come the first time. And I don't know how call this question. Thanks.