1、cors 后台解决跨域
res.header("Access-Control-Allow-Origin", "*"); // 允许所有路径跨域
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By", ' 3.2.1');
res.header("Content-Type", "application/json;charset=utf-8");
eg:
$.get('http://localhost:3000/all',{
name:'xiaohua',
age:18
},function(data){
console.log(data);
})
var express=require('express');
var app=express();
// 解决跨域问题
app.all("/*", function(req, res, next) {
// 跨域处理
res.header("Access-Control-Allow-Origin", "*");
res.header