前台ajax传值,后台接收不到参数问题,mysql You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

2017-12-5 23:33:12 4,493 views

这里rowOwn,columnOwn,areaNameOwn的类型为array,后台用String rowOwn=request.getParameter("rowOwn");是接收不到的 ,其中request.getParameter的参数可以为ajax中data的value名
因为它们的数据类型不同。后台接收到的为字符串。而前台传过去的为数组,所以需要把数组转换为字符串

$.ajax({
              type: "post",
              url: "selectContent",
              async: true,
              data: {
                value: value,
                rowOwn: rowOwn[0].toString(),
                columnOwn: columnOwn[0].toString(),
                areaNameOwn: areaNameOwn[0].toString()
              },
              success: function() {
                console.log(areaNameOwn + "区" + rowOwn + "排" + columnOwn + "列" + value);
              },
              error: function() {
                alert("error");
              }
            });

mysql 保留关键字row ,column
若用上面的关键字来操作sql语句话报错
例如
update student set row="十" column="一" where age="28" and name="mike";
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'column="一" where age="28" and name="mike"' at line 1

0

分享到微信朋友圈

打开微信,点击底部的“发现”,
使用“扫一扫”即可将网页分享至朋友圈。