我有一些用XAJAX创建的简单代码,它用php脚本创建的一些选项替换了select控件的内部HTML。
这在火狐中很好用,但在IE7中就不行了。
在XAJAX论坛上,我找到了this,它基本上是说“在IE中不能真正工作,使用div并用完整的select语句替换它的内部超文本标记语言”。
我这样做了,它很好,除了我有一个jQuery选择器在select控件上工作,它现在不再工作了。
谁有任何想法,或者谁能给我一个很好的jQuery示例,告诉我如何使用jQuery做ajax,这样我就可以完全抛弃XAJAX了?
编辑:
<div id=imgselect>
<select id="images">
<option value="">Then select an image</option>
</select>
</div>
Picture Preview:<br><br>
<div class="img-preview" id='preview'></div>
<script type='text/javascript'>
$('#images').change(function()
{
var image = $(this).val();
var img = $('<img/>').attr('src', image);
$('#preview').html(img);
document.getElementById('picsmall').value = image;
});
</script>
当imgselect
div
的内容被AJAX调用替换时,问题就出现了
发布于 2009-03-25 12:29:35
这个问题现在可以使用
$objResponse->script
命令
为了完整起见,如果任何人想在将来看到,我已经将原始页面设置如下:
<div id=imgselect>
<select id="images">
<option value="">Then select an image</option>
</select>
</div>
然后在我的xajax php文件中
function getphotos()
{
$objResponse = new xajaxResponse();
//this include assigns all the options to the select controll into the $output var
include "photos.photosselect.php";
$objResponse->assign("imgselect", "innerHTML", "$output");
$objResponse->script("$('#images').change(function() {var image = $(this).val(); var img = $('<img/>').attr('src', image); $('#preview').html(img); document.getElementById('picsmall').value = image;});");
return $objResponse;
}
https://stackoverflow.com/questions/666750
复制相似问题