我正在使用.htaccess重写网址,并使用了html基本标记以使其正常工作。
现在,当我尝试发出ajax请求时,出现以下错误:
最佳答案
使用 addHeader
而不是 setHeader
方法,
response.addHeader("Access-Control-Allow-Origin", "*");
上面一行中的
*
将允许 access to all domains
。为了允许
access to specific domain only
:response.addHeader("Access-Control-Allow-Origin", "http://www.example.com");
检查此
blog post
。