添加标题 X-Requested-With: XMLHttpRequest
说明
如果您跟踪该方法,->ajax()它将通过以下功能:
/**
* Returns true if the request is a XMLHttpRequest.
*
* It works if your JavaScript library sets an X-Requested-With HTTP header.
* It is known to work with common JavaScript frameworks:
*
* @see https://wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript
*
* @return bool true if the request is an XMLHttpRequest, false otherwise
*/
public function isXmlHttpRequest()
{
return 'XMLHttpRequest' == $this->headers->get('X-Requested-With');
}
Run Code Online (Sandbox Code Playgroud)
添加标题X-Requested-With: XMLHttpRequest,然后$request->ajax()将返回TRUE。
| 归档时间: |
|
| 查看次数: |
382 次 |
| 最近记录: |