• I am having a problem with inserting some javascript into an admin page I am making. When i try using a js function it says it cant find it. When i check the source code it doesnt seem to have inserted the code into the header. Can anyone help? I am on a tight time constraint. Thanks!

    Here is the code.

    add_action('admin_print_scripts', 'myplugin_js_admin_header' );
    	function myplugin_js_admin_header() // this is a PHP function
    	{
    		// use JavaScript SACK library for Ajax
    		wp_print_scripts( array( 'sack' ));
    		?>
    		<script type="text/javascript">
    		//<![CDATA[
    		function ajax_update_slug( position ){
    			var mysack = new sack( "<?php bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php" );    
    
    			mysack.execute = 1;
    			mysack.method = 'POST';
    			mysack.setVar( "action", "updateFeaturedSlug" );
    			mysack.setVar( "featuered_position", position );
    			mysack.encVar( "cookie", document.cookie, false );
    			mysack.onError = function() { alert('Ajax error in looking up elevation' )};
    			mysack.runAJAX();
    
    			return true;
    		}
    		//]]>
    		</script>
    		<?php
    	} // end of PHP function myplugin_js_admin_header
Viewing 1 replies (of 1 total)
  • Are you trying to add the action from within a class? If so, try adding your action like this:

    add_action('admin_print_scripts', array(&$this,'myplugin_js_admin_header') );

Viewing 1 replies (of 1 total)
  • The topic ‘Problem with “admin_print_scripts”’ is closed to new replies.