huangcong

1. 需现在服务端允许跨域,允许携带cookie

因服务端脚本语言不同,自行搜索设置

2. 前端Ajax跨域请求代码

$.ajax({
                type: "POST",
                url: "http://127.0.0.1:8000/api/login",
                data: JSON.stringify({\'num\': 1}),
                dataType: \'json\',
                xhrFields: {
                    withCredentials: true //允许跨域带Cookie
                },
                success: function(data) {
                    console.log(data)
                }
            })

分类:

技术点:

相关文章: