Convert an HTML Code string to an HTML Tag

1

Good morning. I have the following problem:

I am integrating between the company's mobile application and the VIMEO platform. I'm using oEmbed-type integration, and their documentation ( link ), when I make the request an XML is returned in which one of the elements () comes with the tag already ready to integrate into the site. This part of retrieving the information and passing it to the javscript of the application is already normal, I was able to do it correctly.

The problem occurs when I pass the tag to the html page. It does not interpret as a common html element, but as a text. That way, the video does not load on the page.

I would like to know how I can do this text conversion for a type that is interpreted as an HTML tag, so that the video works correctly.

Below is a code snippet of an attempt I made in the javascript file to perform the conversion from text to HTML element, following some examples I saw when I searched.

modulos : function(idCurso, idMatricula){
    var deferred = new $.Deferred();
    var parser = new DOMParser();//<<<CRIA O ELEMENTO DOM
    fn.load('conteudo.html');

    $.ajax({
        url: window.api_url + '/curso/getModulosCurso',
        method: 'GET',
        data: {idCurso : idCurso}
    }).done(function(response){

        $.each(response, function(i,elem){
            $('#select-carousel').append($('<option>', {
                value: elem.IdModulo,
                text: elem.Titulo,
            }));                
            elem.HtmlVimeo = $.parseHTML(elem.HtmlVimeo, "text/html");//<<<CONVERTE A STRING RECEBIDA EM HTML
        });

Next time, how the code is pulled from the main page.

                    {{if TipoConteudo == 'Vídeo MPEG'}}
                        {{:HtmlVimeo}}  <!-- PUXA A VARIÁVEL HtmlVimeo, QUE CONTÉM A TAG HTML
                    {{/if}}

The following is an image of how the HTML page is interpreting the above code:

NOTE:TomakesurethissnippetofthevariableHtmlVimneo(<iframesrc="https://player.vimeo.com/video/116061334?app_id=XXXXX" width="480" height="272" frameborder="0" title="Power Point - Aula 1" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> ) is correct, I copied and pasted it to the second code location to see if the video would work. The operation was normal, demonstrating that the error is even in this interpretation of the variable as text and not as HTML.

Thank you in advance.

    
asked by anonymous 25.05.2018 / 17:08

0 answers