Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
How to pass blob value through ajax call in javascript?

We are Generating blob value and want to get it inserted into the database through SQL Server. We are able to pass the blob value and through the help of Ajax call we are trying to get it to insert but we are receiving the error Uncaught (in promise) TypeError: Failed to execute 'array buffer on 'Blob': Illegal invocation code. And in WebServices, we are passing it as byte value byte[] BLOB while in SQL we are using var binary(max) to store the value.

async function pdfhandler() {
    let pdfBlob = '1';
    var mystring = "Hello World!";
    pdfBlob = new Blob([mystring]);
    updateblobdata(pdfBlob);
    console.log(pdfBlob);
}

  
function updateblobdata(blobvalue) {
    debugger;
    /// Insert Blob into Database ///
    console.log('updateblobdata called');
    const urlParams = new URLSearchParams(window.location.search);
    const myParamtag = urlParams.get('104');
    const mymodelval = urlParams.get('DuganHosp-0002');

    var wonumval = '104'; var tagnumval = 'DuganHosp-0002';
    var Modeval = 'U';
    var BLOBval = blobvalue;

    $.ajax({

        url: 'TestTool_WebService.asmx/UpdateHtmlBLOBContent',
        data: {
            WoNum: wonumval,
            Tagnum: tagnumval,
            BLOB: BLOBval,
            Mode: Modeval,
        },
        method: 'post',
        dataType: 'json',
        contentType: false,
        processData: false,
        cache: false,
        success: function (data) { },
    });
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can send files only with content-type: multipart/form-data.

function updateblobdata(blobvalue) {
    const formData = new FormData();
    formData.append('blob', blobvalue);

    $.ajax({
        url: 'TestTool_WebService.asmx/UpdateHtmlBLOBContent',
        data: formData,
        method: 'post',
        dataType: 'json',
        contentType: 'multipart/form-data',
        processData: false,
        cache: false,
        success: function (data) { },
    });
}
about 4 years ago · Juan Pablo Isaza Relatório

0

No Still its not working.Its not coming to this point for blob value.

 [WebMethod]
    public void UpdateHtmlBLOBContent(string WoNum, string Tagnum, byte[] BLOB, string Mode)
    {
        string htmldoc = null;
        using (SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConStr1"]))
        {

            SqlCommand cmd = new SqlCommand("TestTool_PrototypeprocBlobRun", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Workorder", WoNum);
            cmd.Parameters.AddWithValue("@Equipment", Tagnum);
            cmd.Parameters.AddWithValue("@HTML_blob", BLOB);
            cmd.Parameters.AddWithValue("@MODE", "U");
            con.Open();
            int i = cmd.ExecuteNonQuery();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                htmldoc = "Success";
            }
            dr.Close();

        }

        Context.Response.Write(htmldoc);
    }
}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda