我试图在提交表单后显示成功消息。我使用jQuery表格插件link使用Spring MVC的jQuery Form插件提交表单后的成功消息
并提交工作正常。就这样:
$('#emailForm').ajaxForm();
现在我想一个提交按钮下添加一个更迭的消息,所以我加了下面一个div:
<input name="submit" type="submit" value="#springMessage('action.save')" />
<div id="emailSuccessMessage">
</div>
,并添加一些更改jQuery代码:
var options = {
target: '#emailSuccessMessage',
success: showResponse
};
$('#emailForm').ajaxForm(options);
function showResponse(responseText, statusText) {
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
我控制器的方法是:
@RequestMapping(value = "/password", method = RequestMethod.POST)
public String changePassword(@Valid @ModelAttribute("editPassword") EditPasswordForm editPasswordForm, BindingResult result) {
if (result.hasErrors()) {
return "editAccount";
}
userService.changePassword(editPasswordForm);
return "editAccount";
}
现在,当我尝试提交时,它可以正常工作,但没有显示任何提示(我添加了一个仅用于测试的提醒)。 showResponse方法如何工作?我是jQuery的新手,我想知道如何实现我的目标。我应该在哪里设置responseText?
感谢
的Dawid
它看起来像一个函数从成功showResponse永远不会被称为..为什么? – Dawid 2011-05-24 21:51:34