I wrote a code that when a consumer click on on a button. contents might be displayed through ajax in wordpress.
I used wp_ajax_{motion} and wp_ajax_nopriv_{motion}. once I load the web page ajax run with none content material and after ajax finish I refresh the web page after which each factor is okay.
I do not know why once I reload the web page or open the web page in one other browser ajax begins with none triggers.
That is my code:
<script>
jQuery( doc ).prepared( operate(){
jQuery( ".pelak-order-type-item" ).click on( operate(){
var knowledge = {
"motion": "get_product_properties",
"no matter": this.id
};
var ajax_url = "'. admin_url( 'admin-ajax.php' ) .'";
jQuery.publish( ajax_url, knowledge, operate(response) {
jQuery("#ajax-content").html(response);
let generated_steps = jQuery( "#pelak_product_title" ).knowledge( "step" );
for ( var i=2; i<=generated_steps; i++ ){
jQuery( "#step"+ i ).conceal();
}
});
} );
} );
jQuery(doc).ajaxStart(operate() {
jQuery( "#step-general" ).conceal();
jQuery( ".pelak-loader" ).present();
}).ajaxSuccess(operate() {
jQuery( ".pelak-loader" ).conceal();
});
</script>
Word: All the above code in in php echo operate and that i copy the associated half and pasted right here.
Thanks on your consideration to this matter.