2015年11月2日
Ajax
push()
方法可向数组的末尾添加一个或多个元素,并返回新的长度。
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()
方法用于把数组中的所有元素放入一个字符串。 元素是通过指定的分隔符进行分隔的。
var arr = new Array(3)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas"
document.write(arr.join("."))
//输出:
George.John.Thomas
Ajax的POST请求
xhr.setRequestHeader("Content-Type",application/json);
xhr.send(json.stringify({
keyword:'c',
other:'test'
}));
Ajax超市设置
xhr.timeout=5000;
xhr.ontimeout=function(){
console.log('timeout!');
}
Last updated
Was this helpful?