我有一个angularjs应用程序托管在本地主机的nginx服务器上,rest服务托管在本地主机的weblogic:7001上。
我试着在角部里面写这篇文章:

$http.post('localhost:7001/testApp/user/login', { username: username, password: password })
            .success(function (response) {
                callback(response);
});

这就是我得到的错误:
XMLHttpRequest cannot load localhost:7001/testApp/user/login. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

最佳答案

您应该在url中指定协议方案(httphttps,…):

$http.post('http://localhost:7001/testApp/user/login', { username: username, password: password })
        .success(function (response) {
            callback(response);
});

10-04 13:52