$request->isAjax() 的實(shí)現(xiàn)
原生的ajax請求,需要加 xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');
window系統(tǒng)
以下是 $request->isAjax() 實(shí)現(xiàn)
$request->isAjax()
public function isAjax(): bool { return $this->header('X-Requested-With') === 'XMLHttpRequest'; }
以下是ajax請求頭
ajax請求瀏覽器會自動發(fā)送 X-Requested-With 頭,用來標(biāo)記是否是ajax請求。并沒有看到你說的requestType頭。
X-Requested-With
requestType
知道了,謝謝