我正在尝试使用Ajax 1.9和struts1.3从服务器获取最新的输出。下面的代码不起作用。
function doAjaxPost()
{
var aRequest = $.ajax({
type: "POST",
url: "/UserAction.do",
data: { user: p }
});
aRequest.done(function(msg)
{
alert( "You have successfully received output!" );
$('#ajaxOutput').html(msg);
setTimeout(doAjaxPost(),15000);
});
aRequest.fail(function(jqXHR, textStatus)
{
alert( "Problem in getting output (" + textStatus + ")." );
});
}
<input type="button" name="start" value="Start" onclick="doAjaxPost();">
<div id="ajaxOutput"></div>
在struts-config.xml中,我有表单定义&amp;动作映射如下
<form-bean name="UserForm" type="com.admin.ui.beans.UserFormBean" />
<action
path="/UserAction"
type="com.admin.ui.action.UserAction"
name="UserForm"
scope="request"
validate="false">
<forward name="success" path="/User.jsp"/>
<forward name="error" path="/errorPage.jsp"/>
</action>
我做错了什么,请指导我。非常感谢您的帮助!提前谢谢。