I'm building a web application with laravel. I'm using jQuery to send ajax to another URL in my server. In ajax, i'm sending an image data which i created using html2canvas library. Here's the code i've written to do that:
html2canvas(document.getElementById("proforma")).then((canvas) => {
ss = canvas.toDataURL("image/png");
});
ajax_template("POST", $(this).attr("mail_ajax"), {imgBase64: ss}, function (response) {
console.log(response);
$("#mail_gonderiliyor").remove();
notification_display("Başarılı!", "Mail gönderildi.", "success");
}, [], function (error) {
$("#mail_gonderiliyor").remove();
notification_display("Hata!", "Mail gönderilemedi.", "danger");
})
ajax_template is a custom function i've written for convention. It sends a basic ajax request without configuring dataType etc. First parameter is the method, second parameter is the URL which i took from the attribute called "mail_ajax" on the element that is clicked. And the third parameter is the data that i'm sending which only has imgBase64 data that i got from html2canvas.
public function offer_save()
{
return response()->json(["this" => \request("imgBase64")]);
}
and this is the php function in the controller that receives the request. Normally the controller function does a different thing but here i've written this to inspect the behavior of the data that i sent.
In the response, request("imgBase64") is set to null for some reason. So i can't send an image data via an ajax request because it sends null. Fyi, the image data is very very long and im guessing that might be the problem. Is there any fix to this or any suggestion u can give me?