0

The following error TypeError: 'append' called on an object that does not implement interface FormData. is being sent to the console log and refers to the line $.ajax({ as per script below.

The error is not clear to this reader, as upon consulting the documentation, there are at least 3 components with Type as well as settings which could set custom types.

      document.getElementById('startButton').addEventListener('click', () => {
        codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) => {
          if (result) {
            console.log(result)
            document.getElementById('result').textContent = result.text
let formData = new FormData();
let CodeParams = {
  code_data: result.text
};
formData.append("code_json_data", JSON.stringify(CodeParams));
$.ajax({
  url: "update",
  type: "post",
  data: formData
  });
              }
          if (err && !(err instanceof ZXing.NotFoundException)) {
            console.error(err)
            document.getElementById('result').textContent = err
          }
        })
        console.log(`Started continous decode from camera with id ${selectedDeviceId}`)
      })

What is incorrect with the declaration of FormData ?

1
  • 1
    Does this helps ?
    – Swati
    Commented Jun 12, 2021 at 13:50

1 Answer 1

0

The ajax block requires both processData and contentType attributes set.

$.ajax({
  url: "update",
  type: "post",
  data: formData
  processData: false,
  contentType: false
  });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.