如何显示里面嵌套表TD警告值嵌套、里面、TD

2023-09-10 19:46:18 作者:江湖皆过往

我打电话阿贾克斯在其中居住的内部​​,如下一环, 我能够提醒值,正确地完美,而迭代循环,我想是显示在&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

什么为x-TEMPL? 演示 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 :)