成功功能中未显示Ajax响应 [英] Ajax response not being shown inside success function

查看:108
本文介绍了成功功能中未显示Ajax响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示代码的ajax响应?当我使用async=true时,显示的yy值只是最后一个值;我需要显示从0a的所有值. async=false可以正常工作.这是我的代码:

for(var jj=0;jj<a;jj++){
                var yy=jj;
                var ins=12
                var rou=13
                /* */
                $.ajax({
                            type:"GET",
                             url:"Select.php",
                             async:false,
                             data:"rou="+rou+
                                 "&ins="+ins,   

                           success : function(t){

                            $("#truk"+yy).text(t);
                            // Response not shown here


                          } //success
                 });              

               }    

解决方案

但是无论如何,这都是您要搜索的ajax调用的结果:

var syncResult = $.ajax('/echo/json/', {
    async: false
});
document.write(syncResult.responseText);

在此处实时查看: http://jsfiddle.net/alligator/6MsuZ/

How do I display ajax response of my code? When I used async=true the yy value shown is only the last value; I need to show it for all value from 0 to a. It works fine with async=false. Here is my code:

for(var jj=0;jj<a;jj++){
                var yy=jj;
                var ins=12
                var rou=13
                /* */
                $.ajax({
                            type:"GET",
                             url:"Select.php",
                             async:false,
                             data:"rou="+rou+
                                 "&ins="+ins,   

                           success : function(t){

                            $("#truk"+yy).text(t);
                            // Response not shown here


                          } //success
                 });              

               }    

解决方案

But anyway it is the result of the ajax call what you are searching for:

var syncResult = $.ajax('/echo/json/', {
    async: false
});
document.write(syncResult.responseText);

See it live here: http://jsfiddle.net/alligator/6MsuZ/

这篇关于成功功能中未显示Ajax响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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