Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 它必须是';正确';允许使用凭据。原产地';空';因此不允许访问_Jquery_Cors_Couchdb - Fatal编程技术网

Jquery 它必须是';正确';允许使用凭据。原产地';空';因此不允许访问

Jquery 它必须是';正确';允许使用凭据。原产地';空';因此不允许访问,jquery,cors,couchdb,Jquery,Cors,Couchdb,我正在尝试以下代码: $.ajax( { xhrFields: { withCredentials: true }, url: 'http://localhost:5984/tdrepo/_design/tdr/_view/repopoolverified?group_level=1', type: "GET", success: function(result) { var $tr = $('&

我正在尝试以下代码:

$.ajax(
    {
         xhrFields: {
        withCredentials: true
    },

    url: 'http://localhost:5984/tdrepo/_design/tdr/_view/repopoolverified?group_level=1',
   type: "GET",

       success: function(result) {

        var $tr = $('<tr/>');
        $tr.append($('<td>').html(result.itemname));
         $tr.append($('<td>').html(result.Repository));
          $tr.append($('<td>').html(result.AIPcount));

            $('.list-order tr:last').before($tr);
$.ajax(
{
xhrFields:{
证书:正确
},
网址:'http://localhost:5984/tdrepo/_design/tdr/_view/repopoolverified?group_level=1',
键入:“获取”,
成功:功能(结果){
var$tr=$('');
$tr.append($('').html(result.itemname));
$tr.append($('').html(result.Repository));
$tr.append($('').html(result.AIPcount));
$('.list order tr:last')。在($tr)之前;
但我得到了这个错误:

凭据标志为“true”,但“访问控制允许凭据”标头为“”。必须为“true”才能允许凭据。因此,不允许访问源“null”。 我启用了CORS: 启用\u cors=true
及 [cors] Originates=*但它仍然不起作用

问题解决了! 我发现我需要使用vim进行以下更改: sudo vim/etc/couchdb/local.ini

启用\u cors=true

[cors] 起源=*

我没有找到[cors],所以我添加了它,但我把它放在了文件的末尾;在[admin]之后

当我把它放在后面时(enable_cors=true
)它成功了。

服务器必须在选项飞行前请求上设置标题,否则将无法发出完整请求