Консоль выдает ошибки синтаксического анализа XML при загрузке содержимого из одного HTML-файла в другойJquery

Программирование на jquery
Ответить Пред. темаСлед. тема
Гость
 Консоль выдает ошибки синтаксического анализа XML при загрузке содержимого из одного HTML-файла в другой

Сообщение Гость »


Я использую Firefox v123.0.1 (64-разрядная версия) для локального просмотра

Код: Выделить всё

index.html
for a static web page that I am developing, and I want to dynamically load the contents of another HTML file into a . My goal with having several HTML files is to organize the contents of my web page so it is easier to maintain and to reduce the amount of data the client needs to load at once, all while not having to write duplicate code surrounding the (e.g., by creating a web page for each state).
When I write the contents directly into the , I do not get XML Parsing Errors, but when I use jQuery 3.7.1 to load the contents from another HTML file, it has a problem with some void elements that are not explicitly closed like instead of as well as some boolean attributes that are not explicitly defined like instead of

Код: Выделить всё

hidden='true'
.
I would like to know:
  • How do I stop these errors from occurring?
  • Why do these errors happen?
  • Is there a better way to accomplish my original goal?
I wrote some code below to demonstrate this problem. The errors are detailed as comments. Notice that there are no errors when the contents originate from

Код: Выделить всё

index.html
, but for some unexpected reason, an error occurs when the same contents originate from or

Код: Выделить всё

hidden.html
.

Код: Выделить всё

index.html

Код: Выделить всё






Test





Load HTML containing <br>


This HTML is from...
index.html




Load HTML containing hidden element


This HTML is from... index.html and this is hidden





function updateContainer(container, filename) {
$(container).load(filename);
}






Код: Выделить всё




This HTML is from...
br.html



Код: Выделить всё

hidden.html

Код: Выделить всё




This HTML is from... hidden.html and this is hidden





Источник: https://stackoverflow.com/questions/781 ... -html-file
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Jquery»