跨域请求nginx

时间:2016-01-29 13:04:02

标签: javascript jquery nginx cross-domain

将申请表http://cluster.vk.araneum.dev/发送至http://aggregator.vk.araneum.dev

浏览器中的Erorr:

XMLHttpRequest cannot load http://aggregator.vk.araneum.dev/getWidget/ultratrade. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://cluster.vk.araneum.dev' is therefore not allowed access. The response had HTTP status code 404.

Nginx config(aggregator.vk.araneum.dev):

  location / {

    root  /var/www/aggregator.araneum.dev/source/web;
    try_files $uri $uri/ /app_dev.php$is_args$args;
     autoindex on;
    index  app_dev.php;

        add_header 'Access-Control-Allow-Origin' *;
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' *;
  }

JS代码:

$(function() {
    $.ajax({
        url: platformDomain+'/getWidget/ultratrade',
        success: function(responce) {
            $('#ultratrade-widget').html(responce.widgetHtml);
        }
    });
});

怎么了?

0 个答案:

没有答案