I am stuck in a very common problem when working with HTML and jQuery AJAX formats, but I have not found a suitable solution that does not yet meet my specific needs ... I use the Codeigniter Framework. Here is the specific situation:
HTML - form with array, address [], for example:
<form id="addressForm" class="form-horizontal" method="post" action="">
<div class="form-group">
<div class="col-lg-9">
<label class="control-label" for="address[name]">Full name</label>
<input name="address[name]" type="text" placeholder="" class="form-control">
</div>
<div class="col-lg-3">
<label class="control-label" for="address[email]">Email</label>
<input name="address[email]" type="text" placeholder="" class="form-control">
</div>
</div>
... and so on
jQuery - AJAX call passing two PHP parameters: identifier and array of addresses are serialized ...
$.ajax({
type: "post",
url: "ajax/updateClientAddress",
dataType: "json",
data: {
id: $('select[name="addresses"]').val(),
address: $("[name^='address[']").serialize(),
}
...
PHP - data processing and client update
...
$addressID = $this -> input -> post('id');
$addressData = $this -> input -> post('address');
...
I would like to know what is missing or not in every part in order to access data in PHP as follows:
$client -> name = $addressData['name'];
Thanks in advance.
andcl source
share