Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!