[英]Loading a popup using ajax
我有一个jsp页面,应该使用ajax加载弹出窗口。 页面内容由用户填写的表单确定。
像这样的东西:
JavaScript的:
ajax('getPage.action', 'content_id', 'form_id');
foo.jsp:
<div id="content_id"></div>
<form id="form_id">
...
</form>
爪哇/春:
@RequestMapping("getPage.action")
MyController extends AbstractCommandController {
RealDto dto = (RealDto)command;
...
return new ModelAndView("foo", data);
}
对我来说最困难的部分是如何轻松地将表单数据作为ajax调用发送。 我可以在这里使用jQuery吗? 表单会动态更改,因此列出表单的所有字段会非常麻烦。
使用Springs XT(我从未拥有)会有帮助吗?
jQuery表单插件可以帮助您轻松地将常规表单转换为Ajax表单。 您只需要一行代码:
$("#myform").ajaxForm(
{beforeSubmit: validate, success: showPopup} );
我不知道jQuery,但对于原型这很容易:
new Ajax.Request('getPage.action', {
parameters: $('form_id').serialize(true),
onSuccess: someMethod
);
查看Prototype API文档 。
该页面包含与jQuery相同的信息: http : //docs.jquery.com/Ajax
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.