Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery ,replaceWith() not working after writing to session from iframe, unless page is refreshed
    primarykey
    data
    text
    <p>I have a function that rewrites dynamically a div after ajax call</p> <pre><code> function showPage(href){ setTitle("",0); $.ajax({ type: "POST", url: href, cache: false, success: function(html){ rewriteContentDiv(html,isNotFade); } }); } function rewriteContentDiv(html, href, isNotFade) { var bodyObj; if($('#content-div').length !=0){bodyObj=document.body;}else{bodyObj=parent.document.body;} $('#content-div', bodyObj).fadeOut("slow", function () { var div = $('&lt;div class="content" id="content-div"&gt;test2&lt;/div&gt;').hide(); div.html(html); $('#content-div', bodyObj).replaceWith(div); $('#content-div', bodyObj).fadeIn("slow"); $('#content-div', bodyObj).find("a").click(function (e) { catchAnchorClick($(this), e) }); }); } </code></pre> <p>I call this function from a page and it works, unless 1 specific circumstance: When inside the "content-div" I have an iframe with a button which writes something to a session with </p> <pre><code>function setObject(key,value){ var session = window.sessionStorage; session.setItem(key, escape(JSON.stringify(value))); } </code></pre> <p>The object does get written to the session, but then the rewriteContentDiv function starts to fail on </p> <pre><code>$('#content-div', bodyObj).replaceWith(div); </code></pre> <p>line, without showing any exception or letting me step into the jQuery function - i debug on chrome 30.0.1599.101 m.</p> <p>If I press "refresh" - the function starts working again, and I see the object in the session storage.</p> <p>Why can it be and what can be done to prevent it?</p> <p>I tried to make an ugly trick of setting </p> <blockquote> <p>"window.location="</p> </blockquote> <p>to the url of itself when in the problematic situation, but it didn't help...</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload