猿问

jQuery 源码中X-Requested-With header 的作用

                // X-Requested-With header

                // For cross-domain requests, seeing as conditions for a preflight are

                // akin to a jigsaw puzzle, we simply never set it to be sure.

                // (it can always be set on a per-request basis or even using ajaxSetup)

                // For same-domain requests, won't change header if already provided.

                if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {

                    headers[ "X-Requested-With" ] = "XMLHttpRequest";

                }

请问这段代码是什么意思呢?

ABOUTYOU
浏览 497回答 1
1回答

狐的传说

添加一个http头用来说明这次的请求是通过XMLHttpRequest进行的
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答