簡體   English   中英

響應數據未通過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”。 如果在這里發布服務器端代碼,那就更好了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM