簡體   English   中英

jQuery ajax簡單發布/獲取

[英]jquery ajax simple post/get

function selectTinNumber(object){   
    $.ajax({
        url: '..//include/crud.php',
        data: 'pin=' + object.value,
        cache: false,
        error: function(e){
            alert(e);
        },
        success: function(e){
            // A response to say if it's updated or not
            alert(e);
        }
    });   
} 

我有用於ajax的代碼,我想用它在我的crud.php中選擇查詢我的數據庫。我有一個名為selectAllPin()的函數,在這里我使用數據pin 我使用pin就像if(isset($_GET['pin'])){我的問題是為什么我總是像這樣的object Object保持警覺。我如何將我的函數selectAllPin()連接到此Ajax,不勝感激

阿賈克斯得到

function selectTinNumber(object){   
    $.ajax({
        url: '../include/crud.php?pin=' + object.value,
        cache: false,
        error: function(e){
            alert(e);
        },
        success: function(e){
            // Response here
            alert(e);
        }
    });   
} 

之所以得到Object對象,是因為您要警告的是對象。 您需要閱讀它的適當屬性,例如e.result 如果要查看所有對象包含的內容,可以使用此

for (var i in e)
{
  alert(i + ": " + e[i]);
}

遍歷對象e的所有屬性。

使用console.log來顯示內容或JSON.stringify,這應該會有所幫助。 我認為可以使用e.data找到數據。

暫無
暫無

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

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