1
我得到以下错误: 跨域请求被阻止:同源策略不允许读取远程资源http://localhost/index.json。这可以通过将资源移动到相同的域或启用CORS来解决。我得到错误:(交叉原点请求被阻止)angular 2 ionic 2
我在下面给出的是我的代码。 任何机构都可以帮助我解决这个问题。
import { Injectable } from '@angular/core';
import { Http ,Response} from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class WebserviceProvider {
constructor(public http: Http) {
console.log('Hello WebserviceProvider Provider');
}
getUser() {
return this.http.get('http://localhost/index.json')
.map((res:Response) => res.json());
}
}
但我使用下面的链接它的到来。 https://conduit.productionready.io/api/profiles/eric。任何机构都可以帮助我使用下面的url http://localhost/index.json –
只需使用Chrome扩展程序:https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi,以便您可以允许CORS。 – Haseoh
确定haseoh,但我正在使用下面的URL它不会来http://myip/get_emp.php?action = getdetails和如何使用本地url? –