【发布时间】:2015-06-12 16:18:39
【问题描述】:
我在 data.push 上收到以下错误。为什么?
Uncaught TypeError: undefined is not a function
在 javascript 中执行此操作时
var data = ({"name": "button", "value": "delete"});
data.push({"id": 456});
console.log(data);
$.ajax({
type: ...
url: ...
data: data,
dataType: "json"
}).done(function(data) {
...
}).fail(function(data) {
...
});
【问题讨论】:
-
data[key]=value允许您为对象指定键+值,而 push() 仅为数组指定值。
标签: javascript