如何在Jquery中动态地将数据发布到iframe.
在这种情况下我真的需要将数据发布到Iframe,我不能使用$ .POST,因为接收的数据是按顺序返回的(缓冲的)
如果你有一个解决方法,当它收到数据时,让jquery处理由$ .POST'返回的数据.我很好奇!
目前我用GETS这样处理它:
var iframe = $('<iframe style="display:none;"></iframe>');
$( "body" ).append(iframe);
iframe.attr('src','server.php?type=getFolders&inode='+nodeData.inode).load(function(){$(this).remove()});
Run Code Online (Sandbox Code Playgroud)
这基本上创建了一个临时的iframe,并让php在ob_flush();flush();返回数据时注入javascript(使用),然后当它完成时,它只是删除iframe来清理.
从iframe中,我用window.parent.主机的方法访问主框架.
这是理想的,但与GET一起使用,如何使用POST进行此操作?
我在jsBin中有以下代码:http://jsbin.com/iRoROvu/1/edit
它基本上在iframe中有一个锚点.如果您点击该链接,您会看到Chrome中没有任何操作,但在Firefox中它只是空白.
这里是jsFiddle中的相同代码:http: //jsfiddle.net/LbNwd/
JavaScript的:
var previewFrame = document.getElementById('preview');
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
preview.open();
preview.write("Hello World!<br/><a href='#'>Click me!</a>");
preview.close();
Run Code Online (Sandbox Code Playgroud)
HTML:
<iframe id="preview"></iframe>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,如果你使用Firefox,它会在现有的iframe中创建另一个iframe ......并继续这样做...就像'Inception'.但相同的代码在Chrome中运行良好.
谁能告诉我为什么?
我有一个针对隐藏 iframe 的表单。这对于 IE 来说工作正常,但是当在 FireFox 中提交表单时没有任何反应。尚未提交。知道是什么造成了差异吗?
表单和 iframe 在这里:
<form name="dial" method="get" target="callout" action="/cgi-bin/make_call.php">
<input type="text" style="width:190px;" id="calling" name="calling" />
<input type="hidden" name="caller" value="<? echo $extension; ?>">
<input type="submit" name="search" class="btn btn-info btn-large" style="width:65px; height: 30px; position:relative;top:-5px;left:-2px; padding:0.2em; " value="Dial" />
</form>
<iframe name="callout" width="0" height="0"></iframe>
Run Code Online (Sandbox Code Playgroud)
正在加载的页面是:
<?
$caller = $_GET['caller'];
$calling = $_GET['calling'];
//Clean the non numbers out of our string
$calling = preg_replace("/[^0-9]/","",$calling);
//If we are dialing a 7 digit number add a 9 to …Run Code Online (Sandbox Code Playgroud) 我在chrome v.12工作.
我有一个jquery调用,它创建一个iframe
$(document).ready(function(){
$('<iframe />').appendTo('body').attr({'id': 'iframeUploader', 'name':'iframeUploader'}).hide();
});
Run Code Online (Sandbox Code Playgroud)
当我使用表单上传时,chrome会打开一个新窗口,而不是定位iframe
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="upload.php?productID=1074" target="iframeUploader">
Run Code Online (Sandbox Code Playgroud)
谁能发现我做错了什么?我把头发拉出来!
谢谢!