我正在研究AspNetCore中的web應用程序,並試圖通過ajax調用從我的控制器獲取數據。Ajax獲取返回ERR_SPDY_PROTOCOL_ERROR
這裏是我的API:
[HttpGet]
public async Task<IActionResult> GetPackWithAllCards(int? packId)
{
if (packId == null)
{
return Json("An error has occured");
}
else
{
var pack = await _context.Packs
.Include(p => p.TagPacks)
.ThenInclude(tp => tp.Tag)
.Include(p => p.CardPacks)
.ThenInclude(cp => cp.Card)
.ThenInclude(c => c.FaceCards)
.ThenInclude(fc => fc.Face)
.ThenInclude(fc => fc.Template)
.Include(p => p.CardPacks)
.ThenInclude(cp => cp.Card.FaceCards)
.ThenInclude(fc => fc.Face.Image)
.Include(p => p.CardPacks)
.ThenInclude(cp => cp.Card.FaceCards)
.ThenInclude(fc => fc.Face.Sound)
.SingleOrDefaultAsync(m => m.PackId == packId);
if (pack == null)
{
return Json("An error has occured");
}
return Ok(pack);
}
}
和我的Ajax調用:
$.get("/pack/GetPackWithAllCards", { packId: pack.packId }, function (pack) {
alert(pack);
});
我的錯誤是百達一樣的,我得到 「無法加載資源:淨:: ERR_SPDY_PROTOCOL_ERROR」 與狀態= 0
我的api正確地返回一個包,但我的ajax調用沒有得到它。
遇到此鏈接,可能會有幫助:https://www.techsupportall.com/fix-err_spdy_protocol_error-permanently/和https://zenguard.zendesk.com/hc/en-us/articles/204423722-Chrome -error-ERR-SPDY-PROTOCOL-ERROR- –
它不起作用 – Elykx