I'm writing a plugin for my wordpress site and am having trouble understanding the jquery ajax requests. In a nutshell, I am trying to get some user meta data loaded when the page loads.
So in my javascript file I have a line:
$.getJSON("http://mysite.co.uk/wp-content/plugins/myplugin/ajax/ajax.php?action=test", function(json) { // do stuff });
So the above DOES get called, but it's the PHP code I'm having trouble with. In the file ajax.php, I am making a database call, but NONE of the usual class information is available. I've tried including the admin ajax page, various other pages from my own plugin (which does work).... not sure what else to do!
The database call method works OK in my plugin code.. but I guess that the ajax.php file is outside the WP framework so that's why it's not working... but I don't know how to get it IN the framework!?
I just need to use the $wpdb->get_results($sql);
command to get my SQL. The error returned from firebug is that I am making a call to an undefined function.
Thanks for any help...