Ajax Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

前端 未结 11 1510
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 16:55

I\'m writing a simple site that takes as input an idiom, and return its meaning(s) and example(s) from Oxford Dictionary. Here\'s my idea:

I send a request to the fol

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 17:39

    add these in php file where your ajax url call

    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Credentials: true ");
    header("Access-Control-Allow-Methods: OPTIONS, GET, POST");
    header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");
    

提交回复
热议问题