Submit form with Ajax- action method does not executed
-
Hello,
I am creating a custom submit form for course subscription.
I defined Ajax query to be executed when submit. Th query sent successfully to php sever but the action method is not executed.
I am using wordpress ajax file (admin-ajax.php) to process the Ajax query.Please find below how it is defined:
**
subscription.js file:
**
jQuery(document).ready(function () {
jQuery( “form” ).on( “submit”, function(e) {
var ajaxurl=””;
jQuery.ajax({
type: “POST”,
url: ajaxurl,
data: {‘action’: ‘action_register_subs’},
success: function () {
}
});e.preventDefault();
});
});**
subscription.php file
**
//enqueue js scripts…..
//add javascript actions
add_action( ‘wp_ajax_action_register_subs’, ‘register_subs);
add_action(‘wp_ajax_nopriv_action_register_subs’, ‘register_subs’);
function register_subs(){
//
}Note:: the “subscription.php” file is created under /child-theme/learnpress/single-course
is there any way to use “LP.ajax” method in my custom files as it is done under the learnpress plugin (“single-course.js” , “profile.js”)?
Thanks in advance.
Asma
- The topic ‘Submit form with Ajax- action method does not executed’ is closed to new replies.