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.

Put that on the page which you call :

<?php
    header("Access-Control-Allow-Origin: *");
?>