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

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - 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了。