提交ckeditor数据到后台保存入库,如果成功返回yes,错误返回false,jquery代码如下:
$("#subAjax").click(function () {
CKupdate(); //在提交表单前需要做以上处理
$.post("getProductDesc.do", $("#form1").serialize(), function (data) {
if (data == "sucess") { alert("成功"); } else { alert("失败"); }
});
});后台处理代码如下:
@RequestMapping("/getProductDesc")
public String getProductDesc(HttpServletRequest req, HttpServletResponse resp)
{
String productDesc = req.getParameter("editor");
.......
}后台怎么返回给前台data值(如果处理成功,返回给前台sucess,处理失败返回前台false),谢谢!!!!另外:productDesc 值是ckeditor控件中的值,要存到mysql数据库中,数据库字段是varchar好、blob好,还是text好。
$("#subAjax").click(function () {
CKupdate(); //在提交表单前需要做以上处理
$.post("getProductDesc.do", $("#form1").serialize(), function (data) {
if (data == "sucess") { alert("成功"); } else { alert("失败"); }
});
});后台处理代码如下:
@RequestMapping("/getProductDesc")
public String getProductDesc(HttpServletRequest req, HttpServletResponse resp)
{
String productDesc = req.getParameter("editor");
.......
}后台怎么返回给前台data值(如果处理成功,返回给前台sucess,处理失败返回前台false),谢谢!!!!另外:productDesc 值是ckeditor控件中的值,要存到mysql数据库中,数据库字段是varchar好、blob好,还是text好。
public String getProductDesc(HttpServletRequest req, HttpServletResponse resp)
{
String productDesc = req.getParameter("editor");
.......
return "sucess";//单词虽然错了,但是你要的
}
不行啊 加了之后弹出框都不弹了 感觉应该是值放到HttpServletResponse中的。以前ajax就是这个做的。
public String getProductDesc(HttpServletRequest req, HttpServletResponse resp)
{
String productDesc = req.getParameter("editor");
.......
resp.write("sucess");
}
resp.getWriter().write("sucess");
就可以了,把值放到返回串里面
和
$.post("getProductDesc.do", $("#form1").serialize(), function (data) {
if (data == "sucess") { alert("成功"); } else { alert("失败"); }
});
里面的getProductDesc.do这个没对上,对上再试试。