jquery ajax简单发帖/获取

时间:2015-01-10 10:23:00

标签: javascript php jquery ajax

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任何帮助表示赞赏< / p>

3 个答案:

答案 0 :(得分:2)

ajax Get

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);
        }
    });   
} 

答案 1 :(得分:0)

你得到对象,因为你警告的东西是对象。您需要阅读它的适当属性,例如e.result。如果要查看所有对象包含的内容,可以使用此

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

迭代对象 e 的所有属性。

答案 2 :(得分:0)

将console.log用于内容或JSON.stringify,这应该有所帮助。我认为数据可以在e.data中找到。