Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp functions ajax get

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' );

//After localizing your JS file, you can use my_ajax_object object in your JS file:

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
Php :: php artisan tinker get records 
Php :: php get sql update from session 
Php :: Drupal 8 / 9 entityTypeManager get multiple comments by cid 
Php :: membership_registration: city or town 
Php :: modifier laravel migration to add a comment a column (MySQL/PostgreSQL) 
Php :: enable mcrypt in php ini in xampp php.ini 
Php :: discord.py Levels 
Php :: how to get session variables from cookie string 
Php :: Laravel appends child when referencing it in attribute function 
Php :: how to use php in a project on localhost 
Php :: php csv to multirow array $_FILES 
Php :: obtener tipo 
Php :: how-to-customize-the-email-verification-email-from-laravel-8 
Php :: Declaration of AppExportsTarefasExport::headings() must be compatible with MaatwebsiteExcelConcernsWithHeadings::headings(): array 
Php :: php thorwable vs exception 
Php :: an einem string etwas anfügen php 
Php :: display rounded price get_price php 
Php :: laravel how to read app/config/app.php debug variable 
Php :: How to return custom error message from controller method validation 
Php :: connecting to database and performing sql queries 
Php :: logout php mysql 
Php :: php mysqli connect to two databases pdo 
Php :: preg_replace encoding 
Php :: php messageformatter 
Php :: preg_replace rules for php 7.3 
Php :: PHP str_rot13 — Perform the rot13 transform on a string 
Php :: laravel One to Many relationship using custom primary keys 
Php :: get vendor store url dokan 
Php :: laravel first or with callback 
Php :: laravel blade all syntex description 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =