简体   繁体   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);
        }
    });   
} 

i have this code for ajax i want to use it to select query my database in my crud.php i have a function called selectAllPin() , where i use data pin . 我有用于ajax的代码,我想用它在我的crud.php中选择查询我的数据库。我有一个名为selectAllPin()的函数,在这里我使用数据pin I use pin as if(isset($_GET['pin'])){ my question is why do i always get alert like this object Object .. How do i connect my function selectAllPin() to this ajax any help is appreciated 我使用pin就像if(isset($_GET['pin'])){我的问题是为什么我总是像这样的object Object保持警觉。我如何将我的函数selectAllPin()连接到此Ajax,不胜感激

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

You get Object object because the thing you are alerting is object. 之所以得到Object对象,是因为您要警告的是对象。 You would need to read it's appropriate attributes such as e.result . 您需要阅读它的适当属性,例如e.result If you want to see what all the object contains, you can use this 如果要查看所有对象包含的内容,可以使用此

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

to iterate through all attributes of object e . 遍历对象e的所有属性。

Use console.log to the the content or JSON.stringify, that should help. 使用console.log来显示内容或JSON.stringify,这应该会有所帮助。 I think the data can be found with e.data. 我认为可以使用e.data找到数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM