Ajax的跨域请求问题

来源:互联网 发布:linux下安装python 编辑:程序博客网 时间:2024/05/16 14:20

在ajax中请求需要跨域时不使用jsonp需要添加如下参数,

$.ajax({               type: "POST",               <#if fileServer?exists && fileServer != "">                     url: "${fileServer}/admin/sysFiles/delete.jhtml",                 <#else>                     url: "${request.contextPath}/admin/sysFiles/delete.jhtml",               </#if>               dataType: 'json',               data:{'id':id},               //添加一下2个参数               xhrFields: {                  withCredentials: true               },               crossDomain: true,               success:function(datas){               }            });

在ie中还需要添加

//IE允许ajax跨域参数    jQuery.support.cors=true;
0 0