Skip to content
Advertisement

Wp return result from sql using AJAX

I need some help i am making a wordpress plug in. when i try to get some rows from sql thro a AJAX post i will get nothing back. Even if i try just to return a string it will stays empty. I Dont get any error . Thank you so much for helping.

Script:

my function:

Advertisement

Answer

You should register and localize your script.

Example: –

then you can use that javascript object in your script to call the ajax callback function remember to add action in ajax request.

in your case you have used

then action will ‘ajax_request’.

try out this code.

Reference :- https://developer.wordpress.org/reference/hooks/wp_ajax_action/

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