doulao5916 2012-08-10 13:51
浏览 63
已采纳

XMLHttpRequest无法加载'url'。 Access-Control-Allow-Origin不允许使用origin'url'

I am getting this error while using this code.

function like (id){
        $.ajax({
                type: "POST",
                url: "../web/like/" + id + "/",
                success: function(response) {
                    // succeed silently
                },
                error: function(response) {
                    // fail silently
                },
            });
}

Now i have looked at a whole bunch of questions with the same error code but this is submitting the ajax request on the same domain whereas all the ones i have seen are from other sources.

Exact error message, XMLHttpRequest cannot load URL/web/like/3/. Origin URL is not allowed by Access-Control-Allow-Origin.

  • 写回答

1条回答 默认 最新

  • duanqin7791 2012-08-14 22:00
    关注

    Put that on the page which you call :

    <?php
        header("Access-Control-Allow-Origin: *");
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效