0
我有一個數據表,我添加一個新行並將其提交給JSP插入數據庫。我在JSP中得到以下錯誤。這段代碼有什麼問題。Java腳本數據庫插入
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 '[object HTMLInputElement]' at line 4] with root cause
JS - Ajax代碼提交到JSP上保存按鈕的點擊
function addRow(table,row)
{
var input = $('input', row);
var params = "id="+input[0].value+"&name="+input[1].value+"&title="+input[2].value+"&code="+input[3].value+"&email="+input[4].value+"&band="+input[5].value+"&location="+input[6].value+"&manager="+input[7].value+"&school="+input[8].value+"&major="+input[9].value+"&years="+input[10].value+"&edu="+input[11].value+"&skills="+input[12].value;
var settings = {
"async": true,
"crossDomain": true,
"timeout":0,
"url": "insertdb.jsp?"+params,
"method": "POST",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache"
},
"processData": false
}
$.ajax(settings).done(function (response) {
var json = JSON.parse(response);
if(json.responseHeader.status == "0")
{
alertify.success("Sucessfully modified the schema field");
location.reload();
//alertify.set({ delay : 5000 });
}
else
{
alertify.error("Error! Please try again");
}
console.log(response);
});
}
MY JSP
<sql:update dataSource="${myDS}" var="result">
insert into emp_profile1 (EMPID, NAME, JOB_TITLE, JOB_CODE, EMAIL, BAND, LOCATION, MANAGER, SCHOOL, MAJOR, YEARS_EXP, EDUCATION, SKILLS) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?);
<sql:param value="${param.id}" />
<c:out value="${param.name}"></c:out>
<sql:param value="${param.name}" />
<sql:param value="${param.title}" />
<sql:param value="${param.code}" />
<sql:param value="${param.email}" />
<sql:param value="${param.band}" />
<sql:param value="${param.location}" />
<sql:param value="${param.manager}" />
<sql:param value="${param.school}" />
<sql:param value="${param.major}" />
<sql:param value="${param.years}" />
<sql:param value="${param.edu}" />
<sql:param value="${param.skills}" />
</sql:update>
response.setContentType("text/html");
<c:if test="${result>=1}">
response.getWriter().print("{'success': true}");
</c:if>
是我的回答有幫助?然後點擊左側的複選標記並向上箭頭鍵,即可接受並上傳它。如果仍有問題,請提供更多信息。 –