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

262
Views
Why i cannot pass data URL through ajax to wordpress function

I'm generating images on WP admin panel and saving it to Media Library. I was working perfectly few months ago. But now if i'm sending dataurl via ajax, i'm not receiving any answers from server a long time, and getting 400 error or 404 after. When i'm removing data url value from ajax call and trying to put string or array, it works ok.

Here is my ajax:

var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
var dataURL  = canvas.toDataURL();

var data = {
   'action'   : 'save_certificate',
   'dataURL'  : dataURL
};

jQuery.post(ajaxurl, data).done(function( response ) {
   console.log(response); 
}).fail(function(xhr, status, error) {
   console.log(xhr);
   console.log(status);
   console.log(error);
}).catch(function(xhr, status, error) {
   console.log(xhr);
   console.log(status);
   console.log(error);
});

and wp function

 add_action( 'wp_ajax_save_certificate', 'save_certificate' ); 

function save_certificate(){        
    print('ok');
    wp_die();
}

Post max size on wp config setted to 128MB UPDATED I've got, that i can send canvas which is less that 2 MB, or array which is less than that value, but why i cannot send bigger files?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

jQuery Code:

jQuery(".add_to_queue").click(function(){

var product_id = jQuery('input[name="product_id"]').val();
var variation_id = jQuery('input[name="variation_id"]').val();


var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
jQuery.ajax({
type: 'POST',
url: ajaxurl, 
data: {"action": "post_word_count", "productid":product_id, "variationid":variation_id},

success: function(response){
console.log(response);

}


});

});

WordPress Hook :

function post_word_count(){
  echo "<pre>";
  print_r($_POST['productid']);
  exit();
}

add_action('wp_ajax_post_word_count', 'post_word_count'); 
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!