1.Trim(string)方法的返回值是一个object,不是string,所以Trim("abc ")!="abc";
2.给div添加滚动条:设定一个高度或宽度,然后style="overflow:auto";
3.如果<form></form>里只有一个<input type='text' />,那么如果有onkeydown方法,则会自动提交,解决方法:再加一个<input type='text' style='display:none;'/>;
4.DWR不支持方法重载,在生成的js文件中,是这样调用的:method=function(){...},因此会调用最后一个方法;
5.Spring mvc 和 ajax一起使用:
When you return a String
from a handler method annotated with @ResponseBody
, Spring will use a StringHttpMessageConverter
which sets the return content-type totext/plain
. However, your request does not have anAccept
header for that content-type so the Server (your Spring app) deems it unacceptable to returntext/plain
.
所以,用HttpServletReponse.getWriter().write("string");否则浏览器会去找string.jsp,当然找不到啦,所以会触发ajax的error事件。
6. $.each实际上也是jquery的自定义函数, 在循环体内return false表示跳出each函数, return true表示跳出这一次循环, 继续执行下一次循环. 所以要是想跳出整个函数, 只有用变量控制。
7.toFixed()方法返回值为字符串。