Я пытаюсь получить доступ и отправить данные со стороны php под названием buy.php в свой javascript, и это выдает ошибку: «Ошибка получения данных свойства: [TypeError: не удалось проанализировать URL-адрес из buy.php] >
Я проверил относительное местоположение, но все равно не работает
// Fetch property data from PHP
function fetchPropertyData() {
fetch('buy.php') //
.then(response => response.json())
.then(data => {
// Log the fetched data to the console
console.log(data);
})
.catch(error => console.error('Error fetching property data:', error));
}
// Call the function to fetch property data when the page loads
fetchPropertyData();
my php code `$conn = new mysqli('localhost', 'root', '', 'realstate_main');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare SQL query to fetch all property details
$sql = "SELECT Email,phone,Address, Size,type, Price,location, Bedroom, Bathroom,listingfor,discription,pictureURL FROM Sellhouse where address='lebu'";
$result = $conn->query($sql);
// Check if any properties are found
if ($result->num_rows > 0) {
// Fetch all property details
$properties = array();
while ($row = $result->fetch_assoc()) {
$properties[] = $row;
}
// Close database connection
$conn->close();
// Output property details in JSON format
echo json_encode($properties);
} else {
// No properties found
echo json_encode(['error' => 'No properties found']);
}
`
Подробнее здесь: https://stackoverflow.com/questions/785 ... om-buy-php
'Ошибка получения данных о свойстве: [TypeError: не удалось проанализировать URL-адрес из buy.php] ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение