Welcome Guest, Not a member yet? Register   Sign In
ajax + POST method - sending PHP an array
#1

[eluser]nikefido[/eluser]
Hi all -

I have an ajax function using the POST method, sending POST data via the "send" method.

It is sending a string that resembles:

Code:
ajax.send("email[][email protected]&email;[][email protected]&email;[][email protected]");
//CI forums is adding the extra ";" in there!

Basically, we are trying to send PHP an array of emails to send multiple emails as part of a projects functionality.

However, in CI, I am testing for
Code:
$this->input->post('email');
//and
$this->input->post('email[]');
Both of which seems to coming up as false.

I am using:
Code:
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
so I don't believe that's the issue.


I was hoping someone might shed some light on the matter.
#2

[eluser]xwero[/eluser]
what does print_r($_POST) display?
#3

[eluser]nikefido[/eluser]
more info:
Code:
doing print_r($_POST)

yields:
Code:
(
[email] => Array
      (
         [0] => [email protected]
      )
)

So it appears to be working the way I want it to! (this is a really neat way to pass arrays to PHP)

However, CI is still coming up as FALSE for the POST var existing.
#4

[eluser]nikefido[/eluser]
sorry, this is my mistake.

there's another variable being tested for that is not getting send via the ajax call.

so this SHOULD be working just fine.

/hits forehead




Theme © iAndrew 2016 - Forum software by © MyBB