惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Help Net Security
Help Net Security
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
C
Check Point Blog
M
MIT News - Artificial intelligence
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
U
Unit 42
D
Docker
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
H
Help Net Security
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
Cloudbric
Cloudbric
Blog — PlanetScale
Blog — PlanetScale
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
S
Security @ Cisco Blogs
V
Visual Studio Blog
The Last Watchdog
The Last Watchdog
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Cyber Attacks, Cyber Crime and Cyber Security
Last Week in AI
Last Week in AI
爱范儿
爱范儿
博客园 - 聂微东
S
Securelist
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
V
Vulnerabilities – Threatpost
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
O
OpenAI News
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - freemobile

得物小程序解析data加解密算法 某物抓数据出现验证码的解析思路 excel中移除编辑限制的宏脚本 广西扬美古镇虚拟旅游 pip3快速下载paddle 2018年上半年越南数字广告营销市场情况 thinkphp5(tp5)中success跳转页面和弹窗问题解决 Could not find com.android.support.constraint:constraint-layout的问题解决 角摩网发布在线制作Epub、Mobi格式的电子书 电子书mobi的格式详解 zendstudio采用xdebug调试,断点不停的解决 jeecms运行出现 Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.解决 rsync进行不同服务器之间的数据同步 Linux常用操作 重置mysql数据库密码 windows下IIS+PHP解决大文件上传500错问题 ecmobile中IOS版本中界面文字不显示的解决 linux下重置mysql的root密码 nginx下rewrite参数超过9个的解决方法
ajax成功返回数据中存在多余字符的处理
freemobile · 2017-09-01 · via 博客园 - freemobile

ajax里有需要判断反馈的字符串是否为“ok”,在浏览器里调试,看到返回的内容明明是“ok”,但是if(“ok”==data)判断为false,用alert打印内容也是ok,但是打印长度的时候却是3。

于是把返回内容每个字符的16进制打出来

  var hexCharCode = [];
  hexCharCode.push("0x");
  for(var i = 0; i < data.length; i++) {
    hexCharCode.push((data.charCodeAt(i)).toString(16));
  }
alert(hexCharCode.join(""));
alert(data.length);

发现内容是0xfeff6f6b,ok前面有不可见字符feff,这个是utf的bom头导致的问题,如何解决?看了些资料,很多人是在代码里去做判断,当然这样可以一劳永逸,不过还有一个简单的方法,就是用ultraedit之类的编辑器把php文件另存为utf8-无bom头的文件,然后返回的内容里就不带feff了。