You’ll need to get the screen id on the screen (or page) in question using get_current_screen()
get_current_screen()->id
Then, hook into it with the following:
function my_script_function() {
if ( strpos( get_current_screen()->id, 'screen_id' ) !== false ) {
wp_enqueue_script( 'my_javascript_handle', 'path/to/my/script.js', 'jquery', '1.0' );
}
}
add_action( 'admin_enqueue_scripts', 'my_script_function' );
This will enqueue your script properly in the WordPress system along with jQuery core (just in case it isn’t already there).
http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/ has a good overview of using jQuery in WordPress. Please note that by default though you can’t use $ to call jQuery as it is in safe mode (the article will show you how to change it from having to use jQuery.
Related Posts:
- Do I require the use of nonce?
- Problem with WordPress Ajax form
- Click loads template via ajax
- How to speed up admin-ajax.php in wordpress
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- How to test nonce with AJAX – Plugin development
- WordPress ajax doesn’t display object method on jQuery .change() function
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- adjust section according to country?
- dynamic dependent select dropdown
- How to disable controls in theme customizer?
- Using data sent via AJAX in multiple functions on a WP plugin
- Function won’t run onclick using Ajax
- Why i can’t get custom fields value or post ID via Ajax?
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Database entry removed on browser refresh, Ajax PHP jQuery
- Ajax filter with loadmore button
- Update $wpdb query with AJAX
- Input field duplicates on form submit by jQuery
- How to call a function from functions.php with ajax?
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Find the method which AJAX GET calls
- ajax form function error
- AJAX: WordPress filters inside $html do not work as intended
- getJSON response to PHP
- ajax problems on loading page [closed]
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- Display notification only once
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Passing jQuery value using Ajax to a page template
- How to set a custom path, for ajax image upload folder in admin?
- admin-ajax.php responding with 0
- Making Quote Plugin more efficient
- How to access function from outside of a class within this class in WP plugin?
- ajax_object is not defined when ajax calls the function
- Returning a value from a PHP page
- Page Reloads Before AJAX Request Finishes
- Why is this Ajax not working?
- Stumped – Ajax Response Returns 0
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- PHP can I add line numbers to file_get_contents()
- Sending jsPDF documents to the server
- Use ajax from function.php
- Ajax return code 400
- doing an ajax request always outputs 0
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Woocommerce add to cart quantity buttons with AJAX
- WooCommerce – Reset quantity input field when variation changes
- class click counter save number
- get post based on category chosen in drop down – The ajax method
- Adding Default Settings to Theme My Login plugin
- Checking for new message using AJAX and PHP. Server overload?
- jQuery not defined
- AJAX request status 200 but no actual “response”
- Conditional Header in wordpress
- Create onClick Event to Re-load a Widget
- Swapping wp_dropdown_categories function with wp_category_checklist
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- How to select the contents in the text view textrea in wp_editor?
- wordpress count link clicks by ip address
- How to access global variable $menu inside a class function
- ajax, right way to do it and make it works?
- How can I remove a function that has been added to wordpress with add_filter?
- Ajax load more posts with multiple tax query
- How to store data from multiple forms using ajax and php
- WordPress Sending data to Ajax with select option
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- how to search users by ajax live search
- what is the best practice to add new field to an api route
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Ajax date_query not working past the first iteration
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Why ajax doesn’t work on certain wordpress hooks?
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- How to call plugin function per site in a multisite?
- AJAX pagination, update current page
- Save Search System
- populate form fields in a loop with ajax
- Change “add to cart” button color based on Woocommerce product category [closed]
- How can I get the values of my WordPress $wpdb query in Jquery?
- Ajax request returns ‘Array’. How to output the actual results?
- How to send Ajax request from my plugin in admin dashboard?
- Ajax load more button for comments wordpress
- How to add a do_action on refreshing of WP customizer?
- Setting value of session with Ajax not working
- AJAX success response is not working but it’s saving my changes
- how to make custom ajax handler?
- [jQuery]Adding shortcode
- Display parent and child taxonomies in separate drop down select fields
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Plugins not working on AJAX requests
- WordPress Custom field Colors
- Fancybox type popup window that’s not an iframe
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?