Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wrote a program that works well in Google Chrome, but I just realized that it is having problems in IE. IE states that this is due to a syntax error given by the use of arrow functions since they are not supported in the latest IE. Can anyone tell me how to change my code to be able to run it on IE?

function removeRow(a, ref, plt, pcs, loc, trk, din) {

  var pro;

  swal("Enter the shipment's tracking information:", {
      content: "input",
      buttons: {
        cancel: true,
        roll: {
          text: "Don't have it",
          value: " ",
        },
        confirm: {
          text: "Submit",
        }
      }
    })
    .then((value) => {

      pro = value;
      //console.log(pro);

      if (pro !== null || pro === ' ') {

        b = '#' + a;
        c = '#H' + a;

        var d = new Date();
        var n = Math.round(d.getTime() / 1000);

        var table = $('#mytable')
          .DataTable();

        // Remove a row by Id:
        table.row(b)
          .remove()
          .draw();

        var url = "delete.php"; // the script where you handle the form input.

        $.ajax({
          type: "POST",
          url: url,
          data: {
            id: a,
            track: pro,
            dateout: n
          },
          success: function(data) {
            //alert(data); // show response from the php script.
            //console.log('Success!');
          }
        });

        swal("Success", "Shipment was entered successfully!", "success");

        if (ref == '') {

        }

        var t = $('#myhistory').DataTable();

        t.row(c)
          .remove()
          .draw();

        var reference = ref;
        var pallets = plt;
        var pieces = pcs;
        var location = loc;
        var carrier = trk;
        var datein = din;
        var dateout = n;
        var rowid = 'H' + a;

        if (datein.length < 12) {

          var month = datein.toString().substring(0, 1);

          if (month == '01') {
            month = 'Jan';
          } else if (month == '02') {
            month = 'Feb';
          } else if (month == '03') {
            month = 'Mar';
          } else if (month == '04') {
            month = 'Apr';
          } else if (month == '05') {
            month = 'May';
          } else if (month == '06') {
            month = 'Jun';
          } else if (month == '07') {
            month = 'Jul';
          } else if (month == '08') {
            month = 'Aug';
          } else if (month == '09') {
            month = 'Sep';
          } else if (month == '10') {
            month = 'Oct';
          } else if (month == '11') {
            month = 'Nov';
          } else if (month == '12') {
            month = 'Dec';
          }

          var day = datein.toString().substring(1, 3);
          var year = datein.toString().substring(3, 7);
          var hour = datein.toString().substring(7, 9);
          var second = datein.toString().substring(9, 11);

        } else {

          var month = datein.toString()
            .substring(0, 2);

          if (month == '01') {
            month = 'Jan';
          } else if (month == '02') {
            month = 'Feb';
          } else if (month == '03') {
            month = 'Mar';
          } else if (month == '04') {
            month = 'Apr';
          } else if (month == '05') {
            month = 'May';
          } else if (month == '06') {
            month = 'Jun';
          } else if (month == '07') {
            month = 'Jul';
          } else if (month == '08') {
            month = 'Aug';
          } else if (month == '09') {
            month = 'Sep';
          } else if (month == '10') {
            month = 'Oct';
          } else if (month == '11') {
            month = 'Nov';
          } else if (month == '12') {
            month = 'Dec';
          }

          var day = datein.toString().substring(2, 4);
          var year = datein.toString().substring(4, 8);
          var hour = datein.toString().substring(8, 10);
          var second = datein.toString().substring(10, 12);
        }

        var tout = new Date();
        var timeout = tout.toString();
        var monthout = tout.toString().substring(4, 7);
        var dayout = tout.toString().substring(8, 10);
        var yearout = tout.toString().substring(11, 16);
        var hourout = tout.toString().substring(16, 18);
        var secondout = tout.toString().substring(19, 21);

        var dateout = monthout + ', ' + dayout + ' ' + yearout + ' at ' + hourout + ':' + secondout;

        var datein = month + ', ' + day + ' ' + year + ' at ' + hour + ':' + second;

        t.row.add([
            reference,
            pallets,
            pieces,
            location,
            carrier,
            datein,
            dateout,
            pro
          ])
          .node()
          .id = rowid;
        t.draw(false);

      }

    });

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
384 views
Welcome To Ask or Share your Answers For Others

1 Answer

I could be missing something, but after a quick skim of your code, only this line appears to use any ES6 syntax:

.then((value) => {

Simply change it to:

.then(function(value) {

If you have much more code and don't want to remove such references by hand, @jonrsharpe's suggestion of a transpiler is a good one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...