简体   繁体   中英

Ajax not able to post base64 string to node js server

I am trying to post data (base64 string) to server. when I JSON.stringify the data on console log. I am getting blank output and i am not able to send the data to server. my ajax code is

base64String=[{data:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ....."}](long string)
    $.ajax({
          url: "http://localhost:3000/",
          type: "PUT",
          data: JSON.stringify(base64String),
          contentType: "application/json",
          success: function (response) {
            console.log(response);
          },
          error: function(jqXHR, textStatus, errorThrown) {
            alert(errorThrown)
          }
        });

a string isn't json. Yu would need to do somethng like:

{ string: <base64> }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM