[eluser]Unknown[/eluser]
Couldn't find any answer to this online, or via the search function, so I decided posting it:
I've got a form, like any other, being posted to an AJAX controller within CodeIgniter. The following code is part of a larger form which is being posted.
Code:
<tr>
<td><label class="checkbox"><input type="checkbox" name="ef1_active" value="1"></label></td>
<td><input type="text" name="ef1_label" value=""></td>
<td><select name="ef1_clang" class="input-small">'.$optionlist.'</select></td>
<td><label class="checkbox"><input type="checkbox" name="ef1_required" value="1"></label></td>
</tr>
<tr>
<td><label class="checkbox"><input type="checkbox" name="ef2_active" value="1"></label></td>
<td><input type="text" name="ef2_label" value=""></td>
<td><select name="ef2_clang" class="input-small">'.$optionlist.'</select></td>
<td><label class="checkbox"><input type="checkbox" name="ef2_required" value="1"></label></td>
</tr>
<tr>
<td><label class="checkbox"><input type="checkbox" name="ef3_active" value="1"></label></td>
<td><input type="text" name="ef3_label" value=""></td>
<td><select name="ef3_clang" class="input-small">'.$optionlist.'</select></td>
<td><label class="checkbox"><input type="checkbox" name="ef3_required" value="1"></label></td>
</tr>
<tr>
<td><label class="checkbox"><input type="checkbox" name="ef4_active" value="1"></label></td>
<td><input type="text" name="ef4_label" value=""></td>
<td><select name="ef4_clang" class="input-small">'.$optionlist.'</select></td>
<td><label class="checkbox"><input type="checkbox" name="ef4_required" value="1"></label></td>
</tr>
The form is being serialized, and pushed to the ajax to be saved with this code:
Code:
var data = {
content : content,
property : property,
data_type : dataType,
form_id : $('#form_id').val()
};
$.ajax({
type: 'POST',
url: url,
data: data,
dataType: 'json',
success: function (result)
{
if(result.html == 'deleted')
{
[removed].reload();
}
else
{
$('#newForm').html('');
}
}
});
The serialized result of the 'content' variable when console.logged:
firstname=1&firstname_required=1&prefix=1&lastname=1&lastname_required=1&homePhone=1&homePhone_required=1&emailAddress=1&emailAddress_required=1&ef1;_label=&ef1_clang=Code&ef2;_label=&ef2_clang=Code&ef3;_label=&ef3_clang=Code&ef4;_label=&ef4_clang=Code
But then when I echo it out in PHP it looks like this:
firstname=1&firstname_required=1&prefix=1&lastname=1&lastname_required=1&homePhone=1&homePhone_required=1&emailAddress=1&emailAddress_required=1&ef1;_label=&ef1_clang=Code&ef2;_label=&ef2_clang=Code&ef3;_label=&ef3_clang=Code&ef4;_label=&ef4_clang=Code
Notice the `;` added on all the `_label` variables...
Tried renaming the variables, placing it on top of the form etc... Nothing works; PHP keeps adding the `;` on those text fields.
Even stripped the controller down to this:
Code:
public function save_form_content()
{
print_r($_POST['content']); exit;
}
Anyone got any idea?
Thanks in advance!