Skip to content

Instantly share code, notes, and snippets.

View doKill's full-sized avatar

拖地僧 doKill

View GitHub Profile
@Faithree
Faithree / gist:f8b84de4a300a6a42c2f4a1a46a08872
Last active July 12, 2019 14:30
关于vue+node前后端分离,前端跨域的方案

昨天在做登陆请求的时候,脑子一抽,想试试原生的ajax来请求后台,这时候我就写下了下面的代码,

var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
                console.log(xhr.responseText)
            } else {
               //错误处理