0
我想实现服务器端分页错开我想加载到浏览器的一些数据的加载。这是我的控制器的动作是什么样子:在ASP.NET核心服务器端分页
[Route("api/meteorites")]
[HttpGet]
public IActionResult GetAll()
{
var meteories = _context.Meteorites.ToList();
var js = new JavaScriptSerializer {MaxJsonLength = Int32.MaxValue};
return new ObjectResult(js.Serialize(meteories));
}
这是我的Ajax请求的样子:
var promiseWrapper = (xhr, d) => new Promise(resolve => xhr(d, (p) => resolve(p)));
Promise.all([
promiseWrapper(d3.json, "StaticFiles/world.geojson"),
promiseWrapper(d3.json, "api/meteorites")
]).then(resolve => {
// Set a timer up here to ask for 500 meteorites every ten seconds
// In your controller action, you are going to need pagination
});
请注意,我还使用D3.js(如果有差别)。 感谢您提前帮助!