i am trying to POST some JSON data in PHP. But something is wrong.
This is my html --
<tbody>
{% for x in sets %}
<tr class="">
<td>
<div class="form-group">
{% if x is defined %}{{x}}</div>{% else %}{% endif %}
</td>
<td><input type="number" class ="first" name ="first"></td>
<td><input type="number" class ="second" name ="second"></td>
<td><span id="txtData"></span></td>
</tr>
{% endfor %}
</tbody>
and this is my script
<script>
$(document).ready(function () {
$("#scoreForm").on('submit', function (e) {
$("#submit").show();
var data = $(this).serialize();
data['first'] = $('#first').val();
data['second'] = $('#second').val();
$.ajax({
url: '/processdata',
type: 'post',
data: JSON.stringify({ Frames : data }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (returnedData) {
So when i POST the data it look like so ---
what i want is that when i post the data ---
["frames": {"first":6, "second": 7}, {"first": 4, "second": 9}]
Do anyone knows where i am making the mistake ! Any advice will be really really appreciable ...

<td><input type="number" CLASS="first" name ="first"></td> <td><input type="number" CLASS="second" name ="second"></td>Change the ID to Class (I've capitalised it so you can see it easier. Then change your javascript to loop through each element and save it in the array.