我收到此错误:XMLHttpRequest无法加载http://api.azharcouncil.com/api/Employees/DeleteEmployee?id=11。当预测从表中删除员工时,预检的响应具有无效的HTTP状态代码405。
数据storage.service.ts:
deleteEmployee(employeeId: any){
let url = 'http://api.azharcouncil.com/api/Employees/DeleteEmployee?id='+employeeId;
let headers = new Headers();
headers.append('Content-Type', 'applications/json')
let options = new RequestOptions({ headers: headers });
return this.http.delete(url, options)
.map(resp => resp.json());
}
employees.component.ts:
onDelete(employeeId: any){
this.dataStorageService.deleteEmployee(employeeId).subscribe(
data => {
console.log(data);
return true;
},
error => {
console.log(error.json().error);
console.error("Error delete employes!");
return false;
}
);
console.log(employeeId);
}
**当我在邮递员中尝试这个网址时,我可以删除员工**
答案 0 :(得分:0)
我认为请求内容类型应该是 application / json 还要更改标题应该是添加标题选项的附加键
<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>