我对axios有一个简单的post请求,该请求带有php脚本,该脚本呈现了一些pdf文件,并且应该返回一个字符串。
现在我收到此错误:
Access to XMLHttpRequest at 'IP:7580/pdfgen/pdfGen.php' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
我在我的php文件中设置了这个
<?php
error_reporting(E_ALL);
header('Access-Control-Allow-Origin: *');
无变化。也尝试过这个:
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, X-Requested-With");
也没有变化。
我的axios呼叫看起来像这样:
axios.post("http://IP:7580/pdfgen/pdfGen.php", this.state)
.then(response => {
report = {...this.state.report};
report.createdAt = reportCreatedAt;
window.open(response.data);
this.setState({report: report, pdf: response.data});
console.log(response);
})
什么可以解决这个问题?
预先感谢
答案 0 :(得分:0)
对我来说可行的解决方案是:
'When I make changes on this, It updates all rows with the entered values. This is original code that I want to make changes.
Private Sub CommandButton2_Click()
Dim i As Integer
For i = 2 To Range("A10000").End(xlUp).Row
If Cells(i, 1) = Label4.Caption Then
Cells(i, 2) = TextBox1.Text
Cells(i, 3) = TextBox2.Text
End If
Next i
MsgBox "Saved!", vbInformation
Unload Me
End Sub