Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Ajax in wordpredss

function my_enqueue() {
      wp_enqueue_script( 'ajax-script', get_template_directory_uri() . '/js/my-ajax-script.js', array('jquery') );
      wp_localize_script( 'ajax-script', 'my_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
 }
 add_action( 'wp_enqueue_scripts', 'my_enqueue' );


jQuery.ajax({
    type: "post",
    dataType: "json",
    url: my_ajax_object.ajax_url,
    data: formData,
    success: function(msg){
        console.log(msg);
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs version abfragen 
Javascript :: how to get value of selected radio button in javascript 
Javascript :: transform js to typescript 
Javascript :: using Canvas with tkinger draw arc 
Javascript :: add function 
Javascript :: $( ) jquery 
Javascript :: wordpress how to read jquery 
Javascript :: javascript flow function 
Javascript :: how to create a new window with a specifc link jquery 
Javascript :: scriptcase transforming local to global variable 
Javascript :: js get data from liocalstorage 
Javascript :: dynamic call function 
Javascript :: mongoose auto delete after time 
Javascript :: Nyadorera 
Javascript :: javascrript Wrap all individual words in a span tag based on their first letter 
Javascript :: google chrome extension v3 react content security policy issue 
Javascript :: angularjs Uncaught ReferenceError: myFunction is not defined at HTMLInputElement.onkeyup 
Javascript :: angularjs getting Error: [$rootScope:inprog] $digest already in progress when changed from Fetch to $http + $q 
Javascript :: How to hide div based on select the dropdown in angular js 
Javascript :: Edit parameter in variable with increment/decrement box and save it 
Javascript :: RegEx Pattern Validations failing on html input 
Javascript :: reduce dot notations to javascript array 
Javascript :: Transfer file to server using rsync 
Javascript :: No enum constant datepicker react native 
Javascript :: slow down an action or event 
Javascript :: phaser rotate matrix 180 
Javascript :: array loop pyramid js 
Javascript :: ip scanner node 
Javascript :: Captalize all words first letter javascript 
Javascript :: CUSTOM_ELEMENTS_SCHEMA 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =