trying to get ajax request to work

trying to get ajax request to work

  1. function loadPages() {
  2.             var url = "/api/ChartAPI";
  3.             $.ajax({
  4.                 url: url,
  5.                 type: "GET"
  6.             }).done(function (resp) {

  7.                 //Get the number of pages.
  8.                 //Consider here the page size as 10

  9.                 var pgSize = resp.length / 10;

  10.                 //If the Result is float, then Round it to 1
  11.                 if (isPgSizeFloat(pgSize)) {
  12.                     pgSize = Math.round(pgSize);
  13.                 }

  14.                 //Add Pages in the DropDown for record Pages
  15.                 var pgHtml = "";

  16.                 for (var i = 1; i <= pgSize; i++) {
  17.                     pgHtml += "<option value=" + i + ">" + i + "</option>";
  18.                 }
  19.                 //Add Page Numbers
  20.                 $("#lstRecPages").append(pgHtml);
  21.             }).on("error", function () {
  22.                 $("#dvMsg").html("Error " + err.status);
  23.             });
  24.         };
I'm using jquery-3.2.1.min.js
I'm getting an error because originally it used the .error function, but that doesn't exist anymore, so I'm trying to use the .On function.
Can someone tell if there's a way to fix this ajax request?