spaceman12 Posted January 21, 2011 Share Posted January 21, 2011 Please help to refresh the src=' ' in within the iframe tag. the code I used is <script type='text/javascript'> var xmlhttp; function callAjax() { var str=document.getElementById('chat').value; if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('iframe_chat').innerHTML=xmlhttp.responseText; } } xmlhttp.open('post', 'forum_chat.php', true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send('chat='+str); } </script> All is working fine except the SRC dont refresh each time the ajax function is called unless i refresh the whole page to view the updates result. thank you Link to comment https://forums.phpfreaks.com/topic/225235-how-to-refresh-src-in-iframe-with-ajax/ Share on other sites More sharing options...
Firemankurt Posted January 28, 2011 Share Posted January 28, 2011 Have you considered http://www.prototypejs.org/api/ajax/updater callAjax = function () { new Ajax.Updater('iframe_chat', 'forum_chat.php', { parameters: {ID: $F('chat')}, onFailure: function(){alert('Error.');} }); } Link to comment https://forums.phpfreaks.com/topic/225235-how-to-refresh-src-in-iframe-with-ajax/#findComment-1166334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.