没有得到任何单词加载项请求的响应

时间:2016-10-07 10:48:18

标签: visual-studio-2015 ms-word xmlhttprequest ms-office word-addins

我提交表单时,我的单词加载项中有一个登录表单,它将用户凭据发送给服务器进行身份验证,我使用下面的代码发送登录请求:

        var xhr = new XMLHttpRequest();    
        xhr.open('POST', 'login_api_url', true);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
        xhr.onload = function (e) {
            if (this.status === 200) {                
               console.log("Success:",this.response);

            } else {
               console.log("Error:",this.response);
            }
        };

        xhr.send("email=email_id&password=******");

当我发送有效的用户凭据时工作正常,但如果我发送了错误的凭据,请求不给予任何回复。

当我通过浏览器(Firefox)发送错误的凭据时,它会返回以下响应:

"NetworkError: 401 Unauthorized - https://login_api_url"
Error: {"status":"error","message":"Unauthorized"}

当我使用visual studio2015运行加载项时,它在我的本地计算机上运行正常,但是远程加载项没有显示任何响应。

请帮我解决一下,为什么代码正在使用本地托管的加载项(使用visual studio 2015),但对于远程加载项,它没有对未经授权的请求做出任何响应。

感谢。

0 个答案:

没有答案
相关问题