Perform . append(); of an iframe when the page is loaded

Asked

Viewed 94 times

0

I’m trying to accomplish a .append(); of a iframe which is stored in comic books. Well, this done and accomplished as follows:

$(document).ready(function(){
    $.get('/viatge/auth/getStreetViewCode&${_csrf.parameterName}=${_csrf.token}',{destinationID: $('#destinationID').val()}, function(data){
        $('#street-view-div').append(data);
    });
});

The callback will return me the iframe complete! Just "appendar" below the div ("street-view-div").

There is an additional detail in my question. Such iframe will be populated within a plugin of "step-by-step", soon I also tried to accomplish in the following way:

$(document).on('ready', '#street-view-div', function(){
        $.get('/viatge/auth/getStreetViewCode&${_csrf.parameterName}=${_csrf.token}',{destinationID: $('#destinationID').val()}, function(data){
        $('#street-view-div').append(data);
    });
});

The above form is obsolete since the jQuery 1.8 If memory serves, then it didn’t work.

Someone would have a solution even if it was palliative for my case?

EDITION

As suggested by colleague André Ribeiro when the user informs the iframe I will "debunk it" in order to store only the attributes that are suitable to work with.

Well, I did a test that was next. I left a static frame in the code as below:

<iframe width="560" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="${destinationModify.streetView.embedCode}">
</iframe>

Where the src attribute will be populated via java parameter. But the result was not quite as expected as shown below:

imagem

It simply didn’t load the contents of the frame correctly! Since in GIFT is formed correctly!

<iframe width="560" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?layer=c&amp;panoid=WritgJx7SbMAAAQJOIX2NA&amp;ie=UTF8&amp;source=embed&amp;output=svembed&amp;cbp=13%2C178.0005991462331%2C%2C0%2C4.175384831223795"></iframe>

Already through jQuery happens it makes the request of the attribute src via AJAX and arrow the attribute, but as the image below shows no result:

inserir a descrição da imagem aqui

  • 1

    What exactly doesn’t work? Wouldn’t it be more interesting if you already have this iframe in the code and only update its src, for example?

  • André Ribeiro, simply iframe is not loaded! Unfortunately I will need the entire iframe as the iframe attributes will vary depending on the case.

  • 1

    Just as you can update src you can return the new attributes and set them in the code.

  • Well I’m thinking it’s gonna have to be this way, because with the whole frame it won’t! When persisting the frame I will "demystify" the main attributes to store on disk and render with AJAX callback. I’ll test and bring the feedback

  • Hi André, sorry for the delay, but I performed the test only by changing the src via Java parameter and it didn’t work. I edited the question for better understanding.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.