Invalid Syntax error in Console Log

 This subject has been brought up before I think.  I really do appreciate everyone's input, it really helps when I'm troubleshooting!  Thanks everyone!

My issue is I'm trying to update a field when a button is clicked.  I think my jquery code is correct but I must be doing something wrong in the Ajax code, it keeps telling me that it's a bad request because of invalid syntax.  Can anyone help?

My code is below:

var addCheckboxes = function(view) {
// add the checkbox to to the header to select/unselect all
$('#' + view.key + '.kn-table thead tr').prepend('<th><input type="checkbox"></th>');
$('#' + view.key + '.kn-table thead input').change(function() {
$('.' + view.key + '.kn-table tbody tr input').each(function() {
$(this).attr('checked', $('#' + view.key + '.kn-table thead input').attr('checked') != undefined);
// add a checkbox to each row in the table body
$('#' + view.key + '.kn-table tbody tr').each(function() {
$(this).prepend('<td><input type="checkbox"></td>');
// on page load
$(document).on('knack-view-render.view_395', function (event, view) {
  //add an update button
  $('<button id="print">Update Labels</button>').insertAfter('.view-header');
//add checkboxes to table
$(function() {
 $('#print').on('click', function() {
           var record_ids = [];
      //populate the record IDs variable using all the checked rows
    $('#' + view.key + 'tbody input[type=checkbox]:checked').each(function() {
     record_ids.push($(this).closest('tr').attr('id'));//record id
    });//closing for the each function
      //turn on the Knack spinner
    //set the variable we want changed
    var data = {
    field_298: 'Yes'
    //set a delay
      var myDelay = 100;
    $(function() {
var selectedRecords = record_ids.length + 1
      function updateRecords(id, records, data) {
      url: '',
      type: 'PUT',
      headers: {'X-Knack-Application-ID':'xxxxx',
                'X-Knack-REST-API-Key': 'xxxxxx',
               },//closing for headers
      data: data,
      if(record_ids.length >0){
      }//closing for if function
      else {
      alert('You have updated' + selectRecords + 'horses');
      }//closing for else statement
      },//closing for success function
      error: function() {
      alert('There was an error updating the labels');
    });//closing for click function
Here is what shows up in the console log:
HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax. (XHR)PUT -

Hello Linda,


In Update(PUT) request you need to attached Record id at end .





Sunny Singla