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";
die;
}
even though I specified the callback function to be this
//console.log(renameDataheader);
$.ajax({
url: slug.ajax_url,
type: 'POST',
data: {
action: slug.ajaxaction, //slug_configureheader
nonce: slug.nonce,
idofpost: slug.pageid,
},
success: function(response) {
alert("Success");
console.log(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
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";
die;
}
even though I specified the callback function to be this
//console.log(renameDataheader);
$.ajax({
url: slug.ajax_url,
type: 'POST',
data: {
action: slug.ajaxaction, //slug_configureheader
nonce: slug.nonce,
idofpost: slug.pageid,
},
success: function(response) {
alert("Success");
console.log(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
In my option, you cant use function of widgets class as ajax callback because widget class should be initiated again.
console.log(response)
does not have the echo "Hello". it prints a big HTML instead. – user145078 Commented Nov 13, 2020 at 13:42