Js方法文本拼接

​ 很多时候,前端处理数据时,需要通过AJAX来完成,而如果返回的结果需要调用其他JS方法的时候,如果写在字符串中会失效,可以这样写讲JS方法转译:\”方法名();\”,例如:

1
2
3
4
5
6
7
8
9
10
11
function getCourseGr(param){
$.post("<%=path%>/test/getList",{
"param":param
},function(result){
var html = "";
for(var index in result){
html += "<input type='button' onclick=\"test('"+result[index].id+"');\">";
}
$("#testDiv").html(html);
});
}

前端页面刷新

  • refresh();刷新
  • window.location.reload();刷新当前页面
  • parent.location.reload();刷新父亲父页面
  • location.reload();刷新当前窗口