Cross-domain requests Access to XMLHttpRequest at 'http: //localhost/index.php/api/user/login'

ajax interface to access backstage encounter error

 

Solution:

It was added in the request header of the requested file php

header('Access-Control-Allow-Origin: *');

  

For example: My background is laravel framework interfaces to write, so in index.php laravel added request headers

 

Background data returned

 

Guess you like

Origin www.cnblogs.com/lishudong/p/12616273.html