У меня есть два разных проекта, и мне нужно как-то передать данные из Project1 в Project2. Поэтому я решил сделать данные Project1 из базы данных как API JSON и использовать страницу Project2 HTML для их вызова. Однако данные не отображаются успешно.
Вот как выглядит файл JSON:
{
"data": [
{
"title": "Corporate Finance",
"responsibilities": "Responsible for financial accounting and reporting, internal controls, budgetary control, variance analysis.",
"requirements": "Candidate must possess at least a Degree in Accountancy or Professional Degree or equivalent.",
"status": "1"
},
{
"title": "Group Reporting Accountant",
"responsibilities": "We are seeking a Group accountant to take full financial responsibility for the Group Consolidation and Reporting. Reporting to the Regional Financial Controller, you will be responsible for formulati",
"requirements": "Prepare monthly financial statements for the business and to consolidate the group accounts.",
"status": "1"
}
]
}
И я попытался использовать AJAX на странице Project2 HTML, чтобы сделать request:
$.ajax({
url: 'http://localhost/dbpass/api/post/read.php',
dataType: "text",
success: function(data) {
// Parse JSON file
var json = $.parseJSON(data);
//Store data into a variable
// Display
$('#results').html(json.data);
}
});
И покажите это на HTML:
<span id="results"></span>
Я довольно новичок в этом, пожалуйста, простите меня, если это какая-то глупая ошибка, спасибо!