fetching results through ajax in wordpress using wpdb class
-
I am working with wordpress. In wordpress I make a page ‘dm_page.php’ and in that use contact form 7 plugin in which I created the dropdownlist. On change event of dropdownlist I am hitting ajax. The code for ajax I wrote in header.php. The file to which ajax is giving the data is ‘getdata.php’ placed in theme folder. I am giving the code of ‘getdata.php’.
<?php global $wpdb; $ddlval = $_POST['ddlval']; $results = $wpdb->get_row('select * from my_dynamictest where lang="'.$ddlval.'"', ARRAY_A); $someArray = []; array_push($someArray,[ 'id' => $results['id'], 'name' => $results['name'] ]); echo json_encode($someArray); ?>I am getting following error from this file in my ajax error callback:
Fatal error: Call to a member function get_row() on null in…
I am not able to figure this out what the error says. Please help. Consider me as total beginner in wordpress
The topic ‘fetching results through ajax in wordpress using wpdb class’ is closed to new replies.