Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyLouvre committed Aug 12, 2016
1 parent 8af8684 commit 6055905
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Expand Up @@ -87,6 +87,18 @@ fetch('/avatars', {
```

###IE6-7 cors

涉及到的参数

jsonpCallbackFunction :  后端生成的函数名, 不传自动生成,与jQuery一致
jsonpCallback: 链接中的名字,不传为`callback`,与jQuery一致
charset: 设置script的字符集

>所有情况下,想跨域,都需要手动设置 credentials: 'include'
>所有情况下,如果想发送请求,想带着cookie, 都需要设置 credentials: 'include'


```javascript
fetch('/users', { //jsonp!!!
credentials: 'include',
Expand All @@ -95,4 +107,21 @@ fetch('/users', { //jsonp!!!
}).then(function(){

})
```
```

###使用fetch下载HTML乱码问题

```
fetch('http://tieba.baidu.com')
.then(res=> res.blob())
.then(blob => {
var reader = new FileReader();
reader.onload = function(e) {
var text = reader.result;
console.log(text)
}
reader.readAsText(blob, 'GBK') //或 UTF8,逐个试
})
```

更多用法见这里 http://www.w3ctech.com/topic/854

0 comments on commit 6055905

Please sign in to comment.