XML read error: incorrect content after an XML element of the document,

0

I am loading ajax when testing in the browser it launches the following error:

   $(document).ready(function () {

    $.ajax({

        url: "otrapagina.html",
        method: "GET",
        dataType: "html",
        success: function (response) {
           $('.lateral').append($(response));
        }
    });
});

code in another page.html

<a href="#" >
    <img src="img/mail.png" alt="Correo-e"/>
    <span>Correo-e</span>
</a>
<a href="#">
    <img src="img/snapchat.png" alt="Snapchat"/>
    <span>Snapchat</span>
</a>
<a href="#" >
    <img src="img/twitter.png" alt="Twitter"/>
    <span>Twitter</span>
</a>

Code in index.html

<aside class="lateral">
            <img src="img/imagen.jpg">     
 </aside>
  • The error message appears in Mozilla: XML read error
  • In Chrome: XMLHttpRequest can not load, origin request are only supported for protocol scheme: http, data, chrome, chrome-extension, https
  • Edge successfully runs the script
  • file: /// C: /xampp/htdocs/pAjax/index.html
  • Use jquery-3.2.1.js by cdn
asked by Developer 02.08.2017 в 20:57
source

1 answer

0

The error is because you are trying to access a local file via file:/ or C: , depending on how the browser interprets it.

I recommend that you do your tests with a Servidor Web , if you are used to Google Chrome applications you can use Web Server for Chrome , which enables a port to access your different explorers.

Just select the folder that contains your HTML files and enter the link that tells you.

Remember that it can be 127.0.0.1 or localhost , in case you have problems with an explorer.

    
answered by 02.08.2017 / 22:30
source