views:

108

answers:

1

I'm working on a script right now for a simple shout box. I was using $.get() before without any issues. I then switched over to $.post() so I can pass Cyrillic characters to php.

I switched over everything to post already in both the javascript and php files. Firebug shows that the variables are not empty and being sent and their is a standard response from the php script, but not the right one. I tried printing the whole $_POST variable scope, but just gives an empty array. What am I doing wrong?

$.post('file.php', { sc_com:'submit', name:userboxVal, color:swatch, msg:escape(msgboxVal) }, function(data) {
    if(data.error) {
        msgbox.focus();
        shoutError(data.error);
    } else if(data.status=='posted') {
        msgbox.val('').focus();
        refreshShouts(opts,'ajax');
    }
}, 'json');

PHP

$sc_com = strip_tags($_POST['sc_com']); // Empty
print_r($_POST); // returns Array()

Not sure why you would need the PHP code for it? The whole thing is over 500 lines, but that is the most important part...

+1  A: 

Try serializing the data before sending it to php? http://stackoverflow.com/questions/271043/jquery-post-empty-array

jostster