每次向服务器发送ajax请求时,我都会在表单上收到此错误
Uncaught TypeError: Cannot call method 'split' of undefined
我正在使用Struts-Jquery插件。
这是我的表格
<!DOCTYPE HTML>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<script
language="JavaScript"
src="utils.js"
type="text/javascript">
</script>
<script
language="JavaScript"
src="validation.js"
type="text/javascript">
</script>
<sj:head />
</head>
<body>
<h3>Register for a prize by completing this form.</h3>
<div id="divErrors"></div>
<s:form action="register" id="form">
<label>UserName</label>
<s:textfield name="userBean.username" />
<s:fielderror />
<sj:submit targets = "form" value="AJAX Submit" />
</s:form>
<audio src="x.mp3" controls>Your browser
does not support the audio element.
</audio>
</body>
</html>
答案 0 :(得分:0)
在提交代码<sj:submit targets = "form" value="AJAX Submit" />
中
你应该在显示行动结果的地方添加div。
例如
<div id="result"></div>
<s:form action="register" id="form">
<label>UserName</label>
<s:textfield name="userBean.username" />
<s:fielderror />
<sj:submit targets = "result" value="AJAX Submit" />
</s:form>
此致 SHAILENDRA