修改AdminLTE的Ajax请求,添加跨域请求头: $.ajax({ url: "http://example.com/data.json", headers: { "Access-Control-Allow-Origin": "*" } }).done(function(data) { console.log(data); });
在服务器端配置CORS规则,允许AdminLTE的请求:
// Node.js Express示例代码 app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); });
// Apache示例代码