Skip to content
Advertisement

ajax get data from custom table WordPress

I am trying to learn how to get the content from a custom database table via wordpress ajax but don’t know how to do this.

file name: process-order.php

JavaScript

AJAX Code file -> size.php

JavaScript

I want the result here

JavaScript

Anyone Plz help me

Advertisement

Answer

You have to bind callback function with the hooks used for ajax call.

Instead of this code

JavaScript

Replace this code and put in functions.php file of your active theme

JavaScript

Flow will be like this: When you click button, ajax call will trigger with action: "get_drawing_size","drawing_id":"drawing_id" data. Here action is important.

WordPress will check for the hook associated with the action name. In your case, it will check for the hook wp_ajax_get_drawing_size for logged in user and wp_ajax_nopriv_get_drawing_size for not logged in user.

Above hooks are not mentioned in your code. So please add those hook and link the callback function. I have attached the code above.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement