0

每次向服务器发送 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>
4

1 回答 1

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>

问候, 谢伦德拉

于 2012-12-25T14:05:17.713 回答