jquery,从网页中的ajax调用更改jqueryui对话框的内容 [英] jquery, change jqueryui dialog box content from a ajax call in the webpage
问题描述
jqueryui 用于显示一个对话框,然后在对话框上单击"dialog_insider" ,而不是在扁平(正确的措词?)网页上,将进行ajax调用.该文件通过ajax调用 html:
jqueryui is used to show a dialog box, then if there is a click the 'dialog_insider' on the dialog box ,not on the flat (correct wording?) webpage , an ajax call will be made. The file in the called through the ajax html:
<div id="dialog" style="border:1px solid green; width:150px; margin:auto;">
<div class="dialog_insider">this is the dialog</div>
<!-- end of class dialog_insider-->
</div>
<!- end of id dialog-->
jquery:
<script type="text/javascript">
$(document).ready(function(){
$("#dialog").click(function(){
my_dialog = $(this).clone();
my_dialog.dialog();
$(".dialog_insider", my_dialog).click(function(){
alert("clicked");
$.post("replace.php",function(response){
});
});
});
});
</script>
replace.php文件包含:
the file replace.php contains:
<script type="text/javascript">
$(document).ready(function(){
alert("hi");
$("dialog_insider",my_dialog).html('4444444');
});
</script>
我在replace.php页面上没有任何功能(即没有警报,没有html更改)
I don't get any functionality(i.e. no alert, no html changing) from the replace.php page
我尝试使用$("opener.dialog_insider",my_dialog).html('4444444');
,但没有结果.
I tried with $("opener.dialog_insider",my_dialog).html('4444444');
, but no result.
解决方案是什么?
推荐答案
要从运行ajax的页面制作javascript,您需要将其绑定到当前文档.
To make javascript from ajax-called page running, you need to apped it to the current document.
并且opener
在您进行AXAJ调用时不起作用,仅在打开的窗口中起作用.
And opener
won't work when you make an AXAJ call, works only with opened window.
$.post("replace.php", {}, function(response){
$('body').append(response);
});
JS将在您追加或执行eval()
;
JS will execute when you append it, or make eval()
;
这篇关于jquery,从网页中的ajax调用更改jqueryui对话框的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!