jquery-jsonp插件解决跨域问题

用jquery-jsonp插件解决ajax跨域问题,既可以实现ajax同样的请求效果,而且server服务端的相关代码也不用做任何改变。

代码如下:

 1 var url="http://localhost:8080/WorkGroupManagment/open/getGroupById"
 2     +"?id=1&callback=?";
 3 $.jsonp({
 4   "url": url,
 5   "success": function(data) {
 6     $("#current-group").text("当前工作组:"+data.result.name);
 7   },
 8   "error": function(d,msg) {
 9     alert("Could not find user "+msg);
10   }
11 });
原文地址:https://www.cnblogs.com/yanduanduan/p/7124987.html