温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

ajax request和normal request有哪些区别

发布时间:2022-01-14 09:42:08 来源:亿速云 阅读:142 作者:小新 栏目:开发技术

这篇文章将为大家详细讲解有关ajax request和normal request有哪些区别,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

ajax请求(asynchronized)与普通请求(synchronized)的报文头(Header)不同:

String reqType = request.getHeader("X-Requested-With");
if (null == reqType) {//normal request}
else if (reqType.equals("XMLHttpRequest")) {//ajax request}

1、request headers

  1. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,p_w_picpath/webp,*/*;q=0.8

  2. Accept-Encoding:gzip, deflate, sdch

  3. Accept-Language:zh-CN,zh;q=0.8,en;q=0.6

  4. Connection:keep-alive

  5. Cookie:BD_HOME=0; BD_UPN=12314353; BAIDUID=6D80EC15FB3F7D55F6CF21531B4789A2:FG=1

  6. Host:www.baidu.com

  7. Referer:http://news.baidu.com/

  8. Upgrade-Insecure-Requests:1

  9. User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

response headers

  1. BDPAGETYPE:1

  2. BDQID:0xcc5e27ca0001088a

  3. BDUSERID:0

  4. Cache-Control:private

  5. Connection:keep-alive

  6. Content-Encoding:gzip

  7. Content-Type:text/html; charset=utf-8

  8. Cxy_all:baidu+1e0afc7905a9c9dcea7d6f252627f95b

  9. Date:Fri, 06 May 2016 06:35:43 GMT

  10. Expires:Fri, 06 May 2016 06:35:22 GMT

  11. Server:bfe/1.0.8.14

  12. Set-Cookie:PSTM=1462516543; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com

  13. Set-Cookie:__bsi=17208040824016918998_00_2870_R_N_6_0303_C02F_N_I_I_0; expires=Fri, 06-May-16 06:35:48 GMT; domain=www.baidu.com; path=/

  14. Set-Cookie:H_PS_PSSID=1442_19713_18281_19805_19899_19559_19807_19843_19902_19861_17001_15263_12288; path=/; domain=.baidu.com

  15. Set-Cookie:BIDUPSID=6D80EC15FB3F7D55F6CF21531B4789A2; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com

  16. Set-Cookie:BD_HOME=0; path=/

  17. Set-Cookie:BDSVRTM=0; path=/

  18. Transfer-Encoding:chunked

  19. Vary:Accept-Encoding

  20. X-Powered-By:HPHP

  21. X-UA-Compatible:IE=Edge,chrome=1

2、Ajax异步request headers

  1. Accept:text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01

  2. Accept-Encoding:gzip, deflate, sdch

  3. Accept-Language:zh-CN,zh;q=0.8,en;q=0.6

  4. Connection:keep-alive

  5. Cookie:BAIDUID=6D80EC15FB3F7D55F6CF21531B4789A2:FG=1; PSTM=1462516543; BD_HOME=0; H_PS_PSSID=1442_19713_18281_19805_19899_19559_19807_19843_19902_19861_17001_15263_12288; __bsi=17208040824016918998_00_2870_R_N_6_0303_C02F_N_I_I_0; BIDUPSID=5081A970DD87C74CFFBADF0B28A1AF39; BD_UPN=12314353

  6. Host:www.baidu.com

  7. Referer:https://www.baidu.com/

  8. User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

  9. X-Requested-With:XMLHttpRequest

Ajax异步response headers

  1. Cache-Control:private

  2. Connection:keep-alive

  3. Content-Length:95

  4. Content-Type:baiduApp/json; v6.27.2.14; charset=UTF-8

  5. Date:Fri, 06 May 2016 06:35:45 GMT

  6. Expires:Fri, 06 May 2016 07:35:45 GMT

  7. Server:bfe/1.0.8.14

  8. Set-Cookie:__bsi=16943568347195085118_00_0_I_R_1_0303_C02F_N_I_I_0; expires=Fri, 06-May-16 06:35:50 GMT; domain=www.baidu.com; path=/

关于“ajax request和normal request有哪些区别”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI