May 8, 201412 yr Hi, i am building a front end developer testing area like js fiddle i have what i want working, it works by loadiing a file and using php file_put_contents to update the file, the way i would like it to work is the posted data to populate the results are (this i can do) the problem i have is if you choose a javascript library like jquery to load into the iframe the iframe needs to be refreshed for the jquery to work and then the results go blank HTML <iframe class="iframe_layout_with_sidebar" src="./files/test.php" id="view"></iframe> AJAX $.ajax({ url: '/convert', type: 'POST', dataType: 'HTML', data: { html: html, css: css, js: js, jquery: jquery, jqueryUI: jqueryUI, ko: ko, option: 'save' }, }) .done(function(data) { document.getElementById('view').contentWindow.location.reload(true); }) php just updates the test.php file with file_put_contents this works but i want it to load the iframe with jquery loaded and with the posted data thank you
May 10, 201412 yr Author Solved this, after the ajax call added .done(function(data) { var result = data; var iframe = document.getElementById('view'); if(iframe.contentDocument) doc = iframe.contentDocument; else if(iframe.contentWindow) doc = iframe.contentWindow.document; else doc = iframe.document; doc.open(); doc.writeln(result); doc.close(); }) this updates the iframe and refreshes the iframe so it works like js fiddle
May 10, 201412 yr Is it also possible to achieve this with meta refresh? Like so (adding this to your PHP file) <meta http-equiv="refresh" content="10"> Just an idea, would this work?
Create an account or sign in to comment