I'm using AJAX to submit a serialized form. The data passed on to the action.php
ends up containing %5B%5D instead of []. Is there anyway of getting back the [], or will the data be able to be handled the same way (i.e. like arrays) in action.php
?
The form is serialized via:
var form_data = $("#form").serialize();
Then I send it through $.ajax
:
$.ajax({
type: "POST",
url: "action.php",
data: {
form_data: form_data,
FrmSubmit: 'SubmitButton'
},
cache: true,
success: function (html) {
$("#show").html(html);
alert("form success");
}
});
The ideal data being passed to action.php
should be something like: name=JohnSmith&color[]=blue&color[]=yellow&meal[]=chicken&meal[]=fish
I am getting instead:
name=JohnSmith&color%5B%5D=blue&color%5B%5D=yellow&meal%5B%5D=chicken&meal%5B%5D=fish
Additional question: I have also tried .param(), but couldn't really make heads or tails of the data received. Every letter ended up being encoded in a key. Could anyone shed light on why this might be?