0
var myNames= ["Chris","Kate","Steve"];
$.ajax
({
cache:false,
    type: "POST",
    url: "check.php?timestamp="+new Date().getTime(),
    data: "myCars[]="+myCars,
    success: function(msg)
         {
 ...
         }
});

with var_dump($myNames) in php page i see

array(1) { [0]=> string(16) "Chris,Kate,Steve" }

but i expect

array(3) {....}

why i see array(1) { [0]=> string(16) "Chris,Kate,Steve" }

2
  • ummm.... you are using POST and GET at the same time Commented Jun 14, 2011 at 5:17
  • It is perfectly legal to send a query string on a POST request. Query strings do not imply GET. Commented Jun 14, 2011 at 5:20

1 Answer 1

1

There's a better way of doing this - just pass an object for data:

var myNames= ["Chris","Kate","Steve"];
$.ajax
({
cache:false,
    type: "POST",
    url: "check.php?timestamp="+new Date().getTime(),
    data: {'myNames': myNames},
    success: function(msg)
         {
 ...
         }
});

jQuery will encode it for you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.