响应数据未通过 JSON 传递


Response Data not passed through json

以下脚本应该为我返回预订的请求,并将我通过 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 获取数据,但是当我提醒响应时,它是空的,我如何通过成功函数传递数据?

看起来你没有得到来自服务器端的良好响应。首先,定义请求的类型,因此在 ajax 请求设置类型中添加类型:"POST"或"GET"。如果您在此处发布服务器端代码会更好。