As a newbie JavaScript programmer, I am struggling to figure out how to make my code work as a function. I want to update the ajax_data array every time I click the add row button.
Fresh JS coder looking for some guidance.
var ajax_data = [{
Type: "Analog Input 0",
Tag: "AI0",
Description: "Description"
}, ]
var new_row = {
Type: "Analog Input 2",
Tag: "AI2",
Description: "Description"
}
$("Add_row").click(function(ajax_data, new_row) {
ajax_data.push(new_row);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button type="button" class="btn btn-primary" id="Add_row" name="button">Add row</button>