Я включаю HTML-страницу с именем test.html на веб-странице. Как показано ниже:Включая HTML-страницу в HTML-страницу с помощью jQuery
<head>
<meta charset="utf-8">
<title>load demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<b>Content I want to Include is here: </b>
<div id="success"></div>
<script>
$("#success").load("test.html", function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
$("#success").html(msg + xhr.status + " " + xhr.statusText);
}
});
</script>
</body>
</html>
я получаю чтение ошибки:
Sorry but there was an error: 0 NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file://machd/.../HTML/test.html'.
Что означает эта ошибка? И как лучше всего это решить?
ли это [ранее вопрос] (http://stackoverflow.com/ вопросы/28453213/failed-to-execute-send-on-xmlhttprequest) help? –
Вам нужен сервер для работы ajax. Попробуйте xampp или аналогичные решения, если у вас их нет – monxas
Локальные файлы ('file: // ...'), как правило, не работают для приложений xhr, попробуйте локальный сервер dev. – swornabsent