如何显示里面嵌套表TD警告值 [英] How to display alert value inside nested table td

查看:118
本文介绍了如何显示里面嵌套表TD警告值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话阿贾克斯在其中居住的内部​​,如下一环, 我能够提醒值,正确地完美,而迭代循环,我想是显示在&LT的值相同; TD> 部分,而不是给警觉,是这可能吗?

i am calling ajax in a loop which is residing inside as below, i am able to alert the value correctly perfectly while iterating the loop, What i want is to show the same value in the <td> section, instead of giving alert, Is this possible?

<!-- The template to display files available for download -->
    <script id="template-download" type="text/x-tmpl">
    {% for (var i=0, file; file=o.files[i]; i++) { %}
        <tr class="template-download fade">

            <td>
               <span>{%=file.name%}</span>
                  <!----- Ajax function call -------->
                      var a= file.name;
                         $.ajax({
                            type: "POST",
                            url: "http://localhost/myappproject/trips_controller/showStatus/",
                            dataType: "text",
                            data: {image_name: a,trip_id: '2'},
                            success: function(msg){ 
                                  alert(msg);//how can i display this value in this place
                           }

                         });
            </td>

        </tr>
    {% } %}
    </script>

关于 X-TEMPL 在这上面code使用

About x-templ used in this above code

  • what is x-templ?
  • Demo

请写信给我,如果你无法理解我的问题,我将试图解释你在一些其他的方式。从两个两天我试过了,终于想到要问天才的人谁看到StckOverflow日常:) -

Please write to me, if you could not understand my question, i will try to explain you in some other way. From two two days i tried , and finally thought to ask Genius people who sees StckOverflow everyday :) –

推荐答案

AJAX = 异步 Ĵ avascipt的 A 第二的 X 毫升

AJAX = Asynchronous Javascipt And Xml

试试这个

<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-download fade">

        <td>
           <span>{%=file.name%}</span>
              <!----- Ajax function call -------->
              var a= file.name;
              $(document).ready(function (){  //run when page load is done
                 $.ajax({
                    type: "POST",
                    url: "http://localhost/myappproject/trips_controller/showStatus/",
                    dataType: "text",
                    data: {image_name: a,trip_id: '2'},
                    success: function(msg){ 
                          return '<span>' + msg + '</span>';
                    }

                 });
              });
        </td>

    </tr>
{% } %}
</script>

或使其SYNCHRON

<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-download fade">

        <td>
           <span>{%=file.name%}</span>
              <!----- Ajax function call -------->
                var a= file.name;
                $.ajax({
                   type: "POST",
                   url: "http://localhost/myappproject/trips_controller/showStatus/",
                   dataType: "text",
                   data: {image_name: a,trip_id: '2'},
                   success: function(msg){ 
                         return '<span>' + msg + '</span>';
                   },
                   async: false
                });
        </td>

    </tr>
{% } %}
</script>

请注意,如果你会使用这个,你挡住/锁定所有其他处理,直到其完成......同样喜欢做无休止的,而在PHP。所以,如果您请求犯规结束。这将导致一个小问题:)

Take care, if you would use this, you block/lock all other processings until its done... Same like doing a endless while in PHP. So if you request doesnt ends.. this will cause a little problem :)

这篇关于如何显示里面嵌套表TD警告值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆