$request->isAjax() 的實(shí)現(xiàn)
原生的ajax請(qǐng)求,需要加 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請(qǐng)求頭
ajax請(qǐng)求瀏覽器會(huì)自動(dòng)發(fā)送 X-Requested-With 頭,用來(lái)標(biāo)記是否是ajax請(qǐng)求。并沒有看到你說(shuō)的requestType頭。
X-Requested-With
requestType
知道了,謝謝