AJAX: XML read error: tag without partner. Expected: / img

1

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

  

XML read error: tag without partner. Expected: </img>

Ajax code hosted in script.js

    $(document).ready(function () {
        $.ajax('otrapagina.html',{

            success: function (response) {
               console.log(response);
            }
        });
    });


<!--codigo en otrapaginahtml-->

<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>

<a href="#">
    <img src="img/mail.png" alt="Correo-e">
    <span>Correo-e</span>
</a>
    
asked by Developer 02.08.2017 в 19:53
source

2 answers

3

You have to close the img tags as the error indicates.

Instead of this:

<img src="img/mail.png" alt="Correo-e">

It should be

<img src="img/mail.png" alt="Correo-e" />

Or this:

<img src="img/mail.png" alt="Correo-e"></img>

Complete:

<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>

<a href="#">
    <img src="img/mail.png" alt="Correo-e" />
    <span>Correo-e</span>
</a>
    
answered by 02.08.2017 в 20:07
1

You are missing the dataType from among more ajax options:

$(document).ready(function () {
  $.ajax({
    url: "otrapagina.html",
    method: "GET",
    dataType: "html",
    success: function (response) {
       console.log(response);
    }
  });
});

Taken directly from link

  

dataType (default: Intelligent Guess (xml, json, script, or html))

     

Type: String

     

The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield to JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string)

That means that jQuery deduced that this is an XML when it should be what you want, with% a% of your ajax function you get the html you want.

    
answered by 02.08.2017 в 20:15