Savan Paun
Savan Paun

Reputation: 1733

wordpress get data from custom table call to ajax error

I am trying to get data from custom table when button click with jquery and ajax but i got error how to solve this.

Fatal error: Call to a member function get_results() on a non-object in C:\xampp\htdocs\getwp\wp-content\plugins\getwp_P\display.php on line 3

My jquery is here

$(document).ready(function() {

$("#display").click(function() {          
  $.ajax({    //create an ajax request to load_page.php
    type: "GET",
    url: "display.php",                   
    dataType: "html",   //expect html to be returned                
    success: function(response){                    
        $("#responsecontainer").html(response); 
        //alert(response);
    }

}); }); });

display.php is here

get_results("SELECT * from `wp_school_post`"); echo ""; echo "ID"; foreach ($rows as $row ) { echo ""; echo "$row->postid"; echo ""; } echo ""; ?>

html button

<input type="button" id="display" class="button" value="Fetch All Data" onClick="fetch_data();" /> 

<div id="responsecontainer" align="center">

any solution

Upvotes: 1

Views: 446

Answers (1)

Yatendra
Yatendra

Reputation: 1306

on top of display.php include wp-config.php or wp-load.php.

Upvotes: 0

Related Questions