jQuery: The Write Less, Do More JavaScript Library

Ajax and array

View: New views
2 Messages — Rating Filter:   Alert me  

Ajax and array

by lionel28 () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No one can help?

Hello, I am posting successfully an array, but for some reason, the first element of the array is always missing.

in the text box I get 7 items:
topic[]=2&topic[]=1&topic[]=3&topic[]=4&topic[]=5&topic[]=6&topic[]=7
the response box displays 6
1,3,4,5,6,7 (missing '2'). If I change the order, then the new one in first position will not post!

        function register(){
                $.ajax({
                        type: "POST",
                        url: "post.php",
                        data:"data=" + document.getElementById("topicarray").value,
                        success: function(html){
                                $("#myresponse").html(html);
                                exit;
                        }

and the php

if($_POST['topic'])
{

$data = implode(',',$_POST['topic'] );

echo $data;
   exit;
}

Please someone help?

Re: Ajax and array

by lionel28 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No one can help me?

lionel28 wrote:
No one can help?

Hello, I am posting successfully an array, but for some reason, the first element of the array is always missing.

in the text box I get 7 items:
topic[]=2&topic[]=1&topic[]=3&topic[]=4&topic[]=5&topic[]=6&topic[]=7
the response box displays 6
1,3,4,5,6,7 (missing '2'). If I change the order, then the new one in first position will not post!

        function register(){
                $.ajax({
                        type: "POST",
                        url: "post.php",
                        data:"data=" + document.getElementById("topicarray").value,
                        success: function(html){
                                $("#myresponse").html(html);
                                exit;
                        }

and the php

if($_POST['topic'])
{

$data = implode(',',$_POST['topic'] );

echo $data;
   exit;
}

Please someone help?
LightInTheBox - Buy quality products at wholesale price!