0

My previously working update function now returns a 405 error when it is run. This is after I added the fileReader functionality to facilitate file uploading for a pictures. How could I now have a HTTP verb error (which is what 405 is to my understanding) if my ajaxCall is untouched from it's working form?

function update()
{

//picture specific upload stuff
var reader = new FileReader();
var file = $('#fileUpload')[0].files[0];
reader.readAsBinaryString(file);
//What is readerEvt?
reader.onload = function (readerEvt)
{
    //get binary data then convert to encoded string
    var binaryString = reader.result;
    var encodedString = btoa(binaryString);

    //normal update fields
    emp = new Object();
    emp.Title = $("#TextBoxTitle").val();
    emp.Firstname = $("#TextBoxFirstname").val();
    emp.Lastname = $("#TextBoxLastname").val();
    emp.Phoneno = $("#TextBoxPhone").val();
    emp.Email = $("#TextBoxEmail").val();
    emp.StaffPicture64 = encodedString;
    emp.Id = localStorage.getItem("Id");
    emp.DepartmentId = localStorage.getItem("DepartmentId");
    emp.Version = localStorage.getItem("Version");
}
ajaxCall("Put", "api/employees", emp)
    .done(function (data) {
        $("#myModal").modal("hide");
        getAll(data);
    })
    .fail(function (jqXHR, textStatus, errorThrown) {
        errorRoutine(jqXHR);
    });
return false;
}
Jaeriko
  • 31
  • 10
  • Have you tried using `FormData` instead of manually encoding the file? – Rory McCrossan Nov 17 '16 at 11:24
  • @RoryMcCrossan No, I have not. I'd imagine that would be something good to look into but I'm more concerned about my identical function working in one project and not in anothr than the method by which it is encoding the string. – Jaeriko Nov 17 '16 at 11:44

0 Answers0