My JSON string looks like this:
{
"main_object":{
"id":"new",
"formData":"language=nl_NL&getExerciseTitle=3213&question_takeAudio_exerciseWord%5B0%5D=3213&Syllablescounter%5B0%5D=3213S&Syllablescounter%5B1%5D=321"
}
}
As you can see I have language=nl_NL
, but I am looking to have it like this -> "language": "nl_NL
and so on, instead of the &
in between.
This is most likely what is causing the long string ->
function saveExerciseAjaxCall() {
$("#my_form").on("submit", function(event) {
event.preventDefault();
$.ajax({
url: 'saveJson.php',
type: 'POST',
data: {
id: getUrlParameter('id'),
formData: $('#my_form').serialize()
},
dataType: 'json',
}).done(function(response) {
});
});
}
The part where it is being serialize()
, but to be honest: I have no idea what to do to change this, I read something about serializeArray()
but that will display it in my JSON file like this -> "name": "exampleForStackOverflow": "value": "TheValueGiven"
something that looks like this.
So does anyone have a solution on how to change my AJAX so it won't end up being one long string? But for it to be like "language": "nl_NL"
etc.?