ChillPenguin
Member
Posted 4 years ago #
I'm writing a plugin that makes use of the AJAX. I thought it would be a good idea to go through the example here: http://codex.wordpress.org/AJAX_in_Plugins
Whenever I click on the button that looks up elevetion, Firebug reports that myplugin_ajax_elevation is not defined. This tells me that
add_action('admin_print_scripts', 'myplugin_js_admin_header' );
does not work. Am I doing something wrong, or is there some other way to make this work?
ChillPenguin
Member
Posted 4 years ago #
This may of some value to anyone who runs into the above problem: the example shown in the page I linked to only works with version 2.2.1 (and above, I assume). I was trying this on a 2.0.x WordPress blog.
I think problem with is that the call to myplugin_elev_lookup should be to myplugin_ajax_elev_lookup. I am guessing that the function defined later function myplugin_ajax_elev_lookup() is what it is supposed to be looking for.
I haven't gotten my own Admin AJAX to work either. It calls the JavaScript part fine, but then doesn't call the php Function.
Reckless
Member
Posted 4 years ago #
Just started developing a plugin and this is where I've also got to! I'm using WordPress 2.5.
The Javascript call is made but when the wp_ajax call is forwarded the expression if ( !isset($wp_filter[$tag]) ) is true (there was no onward filter in the list). It's almost as if the action is no longer hooked which I suppose could be depending on how the session has been configured for the AJAX request. I'm an AJAX and WordPress newbie so I could be wrong!
If anyone has any insight I'd really appreciate it! Thanks in advance!
Reckless
Member
Posted 4 years ago #
Found my issue. I was not loading my plugin objects if the invocation was not an Admin - using is_admin() - so I was partly on the track with the session configuration for the AJAX request. With an AJAX invocation the is_admin call returned false.