k102
k102

Reputation: 8079

extjs ajax post

everyone! i'm trying to create ExtJs form and post some data to my php script. heres the code of the button:

    var btnChk = new Ext.Button({
    text: 'Check',
    handler: function(){
    var conn = new Ext.data.Connection();
    conn.request({
           method:'POST',
           url: 'tmp.php',
           success: function(){alert('ok')},
           failure: function(){alert('not ok')},
           params: { foo: 'bar' }
    });

when i hit this button the message is 'ok', so i guess it's a success. but i can't see any $_POST in my php - it's just an empty array. what i'm doing wrong? (i'm realy new to ext and ajax)

Upvotes: 0

Views: 4218

Answers (1)

James
James

Reputation: 5169

A success return doesn't just mean that the data was sent, but that the file was located and successfully sent data.

What PHP code are you using?

Be sure to use the $_POST variable array and not $_GET

Try the following conn.request code

var conn = new Ext.data.Connection();
conn.request({
    method: 'POST',
    url: 'tmp.php',
    params: {
        foo: "bar"
    },
    success: function(responseObject) { alert(responseObject.responseText); },
    failure: function() { alert("Failed!"); }
});

What does the responseText say?

Upvotes: 1

Related Questions