How to run an ajax call in elementor editor


I am having a strange issue. I am not able to execute an ajax call while in Elementor edit mode.

add_action( 'wp_ajax_slug_configureheader', [ $this, 'rename_configureheader_callback' ] );
add_action( 'wp_ajax_nopriv_slug_configureheader', [ $this, 'rename_configureheader_callback' ] );

and I have a callback function like this

public function rename_configureheader_callback(){
      // there is code in in here
        // post id is from ajax
      update_post_meta($post_id, 'car_model', 157 );
      echo "Hello";

even though I specified the callback function to be this

      url: slug.ajax_url,
      type: 'POST',
      data: {
        action: slug.ajaxaction, //slug_configureheader
        nonce: slug.nonce,
        idofpost: slug.pageid,
      success: function(response) {
        // $('#output').append(response);

I get the alert-success but the callback function never executes. How Elementor prevents the callback function? I am stuck on this for the past two days pls help

Latheesh V M Villa 3 months 0 Answers 7 views 0

Leave an answer