Skip to content
Advertisement

How return array in function() to javascript on wordpress ajax.php with following code:

it may seem stupid, but i’m in it for a week, help me …

the “response” in xhr dev-tools chrome does not leave “0”, it never returns the array I need …

Javascript code to get data from wordpress

JavaScript

PHP file to return data in array json to javascript show results in html.

wp-admin/admin-ajax.php (theme/inc/core/ajax.php)

JavaScript

My language is not very good, i hope you undestand, thanks atentiton!!

Advertisement

Answer

Try ajax callback function in functions.php

JavaScript

Localize your script and pass the admin ajax url

JavaScript

Try Js as like below.

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