Brownman Revival
Brownman Revival

Reputation: 3850

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. 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

Upvotes: 0

Views: 46

Answers (3)

I'm Geeker
I'm Geeker

Reputation: 4637

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

Upvotes: 1

dec
dec

Reputation: 604

Use console.log to the the content or JSON.stringify, that should help. I think the data can be found with e.data.

Upvotes: 0

Roope Hakulinen
Roope Hakulinen

Reputation: 7405

You get Object object because the thing you are alerting is object. You would need to read it's appropriate attributes such as 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.

Upvotes: 0

Related Questions