Asp.net mvc 3 如何使用ajax解决图像的附加问题

Asp.net mvc 3 如何使用ajax解决图像的附加问题,asp.net-mvc-3,Asp.net Mvc 3,我的第一个脚本提供了随机图像,如下所示 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <!-- include Cycle plugin --> <script type="text/javascript" src="http://cloud.github.com/downloads/

我的第一个脚本提供了随机图像,如下所示

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<!-- include Cycle plugin -->
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
<script type="text/javascript">
    var $t = jQuery.noConflict();
    $t(function () {
        $t('.slideshow').cycle({
            fx: 'fade' 
        });
    });
</script>

var$t=jQuery.noConflict();
$t(函数(){
$t('.slideshow')。循环({
外汇:“褪色”
});
});
当我添加一些像这样的图片时,它就起作用了

<div class="news_area_left">
     <div class="slideshow" style="position: relative; ">
        <img src="../../banner_image/nemo.jpg" width="154px" height="108px"/>
  <img src="../../banner_image/up.jpg" width="154px" height="108px" />

</div>
    </div> 

但是当我添加我的第二个脚本时,它可以得到你可以看到的图像

<script type="text/javascript">

    $(function () {

        $.ajax({
            type: "get", url: "Home/Oku", data: {}, dataType: "json",
            success: function (data) {

                for (var i = 0; i < data.length; i++) {

                   var newFirmDiv= $(' <img src="../../banner_image/' + data[i] + '" width="154px" height="108px"/>');
                    $(".slideshow").append(newFirmDiv);

                }
            }
        });
    });

</script>

$(函数(){
$.ajax({
类型:“get”,url:“Home/Oku”,数据:{},数据类型:“json”,
成功:功能(数据){
对于(变量i=0;i
最后,我尝试在我的“幻灯片演示”中使用我的动态图像,但效果不起作用

<div class="news_area_left">
     <div class="slideshow" style="position: relative; ">
       </div>
    </div>

您需要运行
$t('.slideshow')。在动态插入图像后循环运行。您还需要附加到“slideshow”类,而不是“firmShowCase”类

看到我创建的这个JSFIDLE了吗

HTML

<div class="news_area_left">
     <div class="slideshow" style="position: relative; ">
         <img src="http://activephilosophy.files.wordpress.com/2009/09/number1.jpg" width="154px" height="108px"/>
         <img src="http://www.clker.com/cliparts/h/Y/i/C/Y/W/red-rounded-square-with-number-2-md.png" width="154px" height="108px"/>
     </div>
</div>​
JavaScript

var $t = jQuery.noConflict();

var newFirmDiv = $t('<img src="http://www.mosamuse.com/wp-content/uploads/2012/05/number3.png" width="154px" height="108px"/>');
$t(".slideshow").append(newFirmDiv);

var anotherDiv = $t('<img src="http://2.bp.blogspot.com/-_A_8UYb0zIQ/Te5lpI9iZ3I/AAAAAAABgWk/sErDyHjEhPw/s1600/number-4.jpg" width="154px" height="108px"/>');
$t(".slideshow").append(anotherDiv);

$t(function() {
    $t('.slideshow').cycle({
        fx: 'fade'
    });
});
var$t=jQuery.noConflict();
var newFirmDiv=$t(“”);
$t(“.slideshow”).append(newFirmDiv);
var anotherDiv=$t(“”);
$t(“.slideshow”)。追加(另一个div);
$t(函数(){
$t('.slideshow')。循环({
外汇:“褪色”
});
});

您能用更新的代码更新您的答案吗。如果你可以发布HTML,JavaScript和任何相关的CSSI都无法从你的代码中分辨出哪些脚本以什么顺序运行,但看起来你在调用
$t('.slideshow')后正在将img标记插入幻灯片。循环
。再次检查我的JSFIDLE,我正在调用
$t('.slideshow')。插入img标记后循环