簡體   English   中英

為什么數據在ajax中顯示未定義

[英]why data is showing undefined in ajax

我正在調用ajax調用,其中向數組提供數據,當我要在控制台中調試此代碼時向我顯示data undefined為什么?

在您的第一個ajax調用的success功能中,您具有以下功能:

success: function (response) {
    orderId = data;
    if (data != null) {
        orderStatus = "Order has been placed successfully.";
    }
}

請注意,您已經調用了回調response的參數,但是隨后使用了data 該代碼引述應該會失敗,並ReferenceError ,因為沒有data在該回調范圍(你所擁有的唯一的地方var data是另一個回調內部 )。 我假設您已經在未引用的代碼中聲明了它。

我認為您的意思是response ,而不是data

success: function (response) {
    orderId = response;
    if (response != null) {
        orderStatus = "Order has been placed successfully.";
    }
}

暫無
暫無

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

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