sending javascript array to external php file using POST

Posted by user1472224 on Stack Overflow See other posts from Stack Overflow or by user1472224
Published on 2012-07-02T15:07:41Z Indexed on 2012/07/02 15:15 UTC
Read the original article Hit count: 194

Filed under:
|
|
|

I am trying to send a javascript array to an external php page, but the only thing the php page is picking up is the fact that I am sending array, not the actual data within the array.

javascript -

var newArray = [1, 2, 3, 4, 5]; 

        $.ajax({
            type: 'POST',
            url: 'array.php', 
            data: {'something': newArray}, 
            success: function(){
                alert("sent");
            }
        });         

External PHP Page -

<?php 
    echo($_POST['something'])); 
?>

I know this question has been asked before, but for some reason, this isn't working for me. I have spent the last couple days trying to figure this out as well. Can someone please point me in the right direction.

current output (from php page) - Array (thats all the page outputs)

© Stack Overflow or respective owner

Related posts about php

Related posts about AJAX