demo1. 模拟用字符串调用js 函数
function dataQuery() {
var strFun = "testCallBack";
var strParam = "param";
//Create the function
var fn = window[strFun];
//Call the function
fn(strParam);
}
function testCallBack(str) {
alert(str);
}
demo2. 模拟springmvc controller回调js函数
controller
@RequestMapping(/doCallback}
@ResponseBody
public String doCallback() throws IOException {
// 上传文件
String url = **;
// 调用前端js回调函数
return "<script type='text/javascript'>updatepropImgCallBack('" + url + "');</script>";
}
js
function updatepropImgCallBack(url){
alert('上传完成返回的url是'+url);
}