Код: Выделить всё
Football-Manager-Analysis/
├── templates/
│ └── index.html
├── importData.PHP
├── app.py
Код: Выделить всё
Scouting and Transfer Market Analysis Tool
Scouting and Transfer Market Analysis Tool
Load Data
Run Data
function loadFile() {
const input = document.getElementById('fileInput');
const file = input.files[0];
const reader = new FileReader();
reader.onload = function(e) {
const parser = new DOMParser();
const doc = parser.parseFromString(e.target.result, 'text/html');
const table = doc.querySelector('table');
document.getElementById('tableContainer').innerHTML = table.outerHTML;
};
if (file) {
reader.readAsText(file);
} else {
alert('Please select a file.');
}
}
function runData() {
const table = document.querySelector('#tableContainer table');
if (!table) {
alert('No data loaded. Please load data first.');
return;
}
const data = extractTableData(table);
sendDataToServer(data);
}
function extractTableData(table) {
const rows = table.querySelectorAll('tr');
const data = [];
rows.forEach(row => {
const cells = row.querySelectorAll('th, td');
const rowData = [];
cells.forEach(cell => {
rowData.push(cell.textContent);
});
data.push(rowData);
});
return data;
}
function sendDataToServer(data) {
fetch('../importData.PHP', { // Adjusted to use a relative path
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ tableData: data })
})
.then(response => response.json())
.then(result => {
alert('Data successfully sent to the server');
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while sending data to the server');
});
}
Код: Выделить всё
127.0.0.1 - - [22/May/2024 00:14:37] "GET / HTTP/1.1" 200 -Код: Выделить всё
127.0.0.1 - - [22/May/2024 00:14:42] "POST /importData.PHP HTTP/1.1" 404 - Я проверил существование файла и разрешения, и я использую относительный путь. Что может быть причиной этой ошибки 404 и как ее устранить?
Подробнее здесь: https://stackoverflow.com/questions/785 ... -html-file
Мобильная версия