Does wp_localize_script call a Javascript Function or Simply Pass PHP Parameters to It

Easy question: I’m trying to understand wp_localize_script. Does wp_localize_script call a JavaScript function or does it simply pass PHP parameters to JavaScript? I want to pass PHP parameters to a JavaScript function and call the JS function. 1 Answer 1 wp_localize_script takes an array of data (in PHP) spits out a javascript. It’s a way … Read more

Ajax call theme functions from front

Here’s what I try to do : calling a function in my theme functions.php from the front of my theme. So, on the front : $(document).on(‘click’,’.btn-vote’,function(e){ e.preventDefault(); var $that = jQuery(this); var id = $that.attr(‘data-id’); var data = { ‘action’: ‘voteIncrementer’, ‘id’: id };, data,function(response){ // ajaxurl is defined in footer.php > var ajaxurl=”<?php … Read more

add_action and Ajax

I’m developing a plugin and I’ve started from WPPB and WordPress 4.3.1. I’ve named it dogmaweb. I need to submit a form to the plugin via Ajax. The form is created by the plugin itself. In my class-dogmaweb.php I’m trying to add the action that processes the form data server side, and here is what … Read more

Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)

Been looking for some help changing a jQuery.ajax() request into vanilla XMLHttpRequest for WordPress, but not really finding what I want. Can anyone help me reformat the below into vanilla JavaScript XMLHttpRequest? $.ajax({ data: { ‘action’: ‘work_hour_form_handler’, ‘work_hours_start’: document.getElementById(‘work-hours–start’).value, ‘work_hours_end’: document.getElementById(‘work-hours–end’).value, ‘break-hours_start’: document.getElementById(‘break-hours–start’).value, ‘break-hours_duration’: document.getElementById(‘break-hours–duration’).value, ‘working_days’: document.getElementById(‘working-days’).value }, headers: {}, method: ‘post’, url: fpm_ajax.ajax_url }).done(function … Read more

ajax call in wordpress front end

In my plugin i’m using two ajax calls in back end. that worked well. but to provide the same functionality in front end i loaded the copy of these two functions with another names and my code is: in my plugin main file: function my_action_callback(){ global $wpdb; if (@$_POST[‘id’]) { $daty = $wpdb->get_results(“select eemail_id,eemail_content,eemail_subject from … Read more