【问题标题】:Response Data not passed through json响应数据未通过 json
【发布时间】:2013-11-17 10:21:13
【问题描述】:

以下脚本应该为我返回预订的请求并将我通过 json 获得的数据附加到 html。

function readUsers() {
    //display ajax loader animation
    $( '#ajaxLoadAni' ).fadeIn( 'slow' );

    $.ajax({
        url: 'user_transactions/get_request',
        dataType: 'json',
        success: function( response ) {
            alert(response)
            for( var i in response ) {
                response[ i ].updateLink = updateUrl + '/' + response[ i ].id;
                response[ i ].deleteLink = delUrl + '/' + response[ i ].id;
            }

            //clear old rows
            $( '#records' ).html( '' );

            //append new rows
            $( '#readTemplate' ).render( response ).appendTo( "#records" );

            //hide ajax loader animation here...
            $( '#ajaxLoadAni' ).fadeOut( 'slow' );
        }
    });
} // end readrequest

我可以从 url 获取数据,但是当我提醒响应时,它是空的,如何通过成功函数传递数据?

【问题讨论】:

    标签: java php jquery json


    【解决方案1】:

    您似乎没有从服务器端获得良好的响应。首先,定义您请求的类型,因此在您的 ajax 请求设置类型中添加类型:“POST”或“GET”。如果您在此处发布服务器端代码会更好。

    【讨论】:

      猜你喜欢
      • 2014-01-08
      • 2016-10-25
      • 1970-01-01
      • 1970-01-01
      • 2017-11-06
      • 1970-01-01
      • 1970-01-01
      • 2014-05-12
      • 1970-01-01
      相关资源
      最近更新 更多