【发布时间】:2014-03-07 08:45:48
【问题描述】:
我正在尝试使用 ajax 发布到服务器上的 json 文件 (API)。在舞台上我拖动两个 Kineticjs 形状,当我停止拖动形状时,我希望能够将新的 x 和 y 坐标保存到服务器上的 json 文件中。 问题是我不能这样写:
data: JSON.stringify({ 'x': '(this).getPosition().x', 'y': '(this).getPosition().y' })
我得到的错误是:
传入的变量不是数组或对象。
无效查询:update T_ZigbeeNodes set x=(, y=(, plan=( where ID=''
您的 SQL 语法有误;请查看与您的 MySQL 服务器版本相对应的手册以获取正确的语法靠近 'y=(, plan=( 其中 ID=''' 在第 1 行。
var getIthData = $.ajax({
type: 'POST',
url: 'http://192.168.8.143/api/v11/plan/',
dataType: 'json',
data: JSON.stringify({ 'x': '(this).getPosition().x', 'y': '(this).getPosition().y' }),
success: function(resultData) {
alert("Post x coord and y coord and Plan, Complete!");
}
});
getIthData.error(function() {
alert("Something went wrong. Cant Post x coord and y coord and Plan");
});
谁能告诉我如何解决这个问题?
【问题讨论】:
-
不要将 (this).getPosition().x 放在引号中。与第二次调用 y 相同。
-
@aaronfrost 嗨,好的,我明白了。但我知道同样的错误...
标签: javascript jquery ajax json api