> For the complete documentation index, see [llms.txt](https://note.niefee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://note.niefee.com/summary-1/11/2015-nian-11-yue-2-ri.md).

# 2015年11月2日

## Ajax

`push()` 方法可向数组的末尾添加一个或多个元素，并返回新的长度。

```javascript
var arr = new Array(3)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas"

document.write(arr + "<br />")
document.write(arr.push("James") + "<br />")
document.write(arr)


//输出
George,John,Thomas
4
George,John,Thomas,James
```

`join()` 方法用于把数组中的所有元素放入一个字符串。 元素是通过指定的分隔符进行分隔的。

```javascript
var arr = new Array(3)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas"

document.write(arr.join("."))

//输出：
George.John.Thomas
```

Ajax的POST请求

```javascript
xhr.setRequestHeader("Content-Type",application/json);
xhr.send(json.stringify({
    keyword:'c',
    other:'test'
    }));
```

Ajax超市设置

```javascript
xhr.timeout=5000;
xhr.ontimeout=function(){
    console.log('timeout!');
}
```
