JSONP简单实践

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mbh12333/article/details/84952829

JSONP简单实践

<script>
    function handleResponse(response){
        console.log(response);
    }
    var script = document.createElement("script");
    script.src = "http://localhost:8088/C1-Planning/formDefinitionAction!loadFormTree.action?callback=handleResponse";
    document.body.appendChild(script);
</script>

后端返回 handleResponse(…) 字符串,前端就会调用了。

 response.getWriter().print("handleResponse("+JSONUtil.toJson(results)+")");

http://www.runoob.com/json/json-jsonp.html

猜你喜欢

转载自blog.csdn.net/mbh12333/article/details/84952829