$.ajax({ type:"post", url:,
success:function(data){ } });
Udalo mi sie zrobic takie cos:
plik rw-ajax-search
function rwas_show_searcher() { echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>'; ?> <script type='text/javascript'> $(document).ready(function(){ $('#submit').on('click', function(event){ $.ajax({ type:'POST', dataType: 'html', success:function(data){ $('#result').html(data); } }); event.preventDefault(); }); }); </script> <?php }
plik rwas_show.php
require RWAS_PATH . '/model/RwAjaxSearch.php'; $model = new RwAjaxSearch(); $result = $model->show_result(); foreach ($result as $row) { }
plik RwAjaxSearch
class RwAjaxSearch { private $tableName; private $wpdb; public function __construct() { $prefix = $wpdb->prefix; $this->tableName = $prefix . "posts"; $this->wpdb = $wpdb; } public function show_result(){ $query = "SELECT * FROM wp_" . $this->tableName . " ORDER BY id DESC;"; return $this->wpdb->get_results($query, ARRAY_A); } }
i po wyslaniu rzadania otrzymuje:
Notice: Trying to get property of non-object in C:\xampp\htdocs\wp\wp-content\plugins\rw-ajax-search\model\RwAjaxSearch.php on line 8 Fatal error: Call to a member function get_results() on a non-object in C:\xampp\htdocs\wp\wp-content\plugins\rw-ajax-search\model\RwAjaxSearch.php on line 15
ocb? Tzn wiem co to za blad ale dlaczego on wystapil