i think the script.js file is not loading properly. if its loading then the function should work as expected.
are you referencing the complete path of script in your script.js call? like
<script type="text/javascript" src="https://wordpress.stackexchange.com/questions/256287/some-domain.com/path/widget.js"></script>
try opening that file from page source and see if its loading the correct js file?
its always best practice to use wp_enqueue_script function for loading js files.
Related Posts:
- Most efficient way to add javascript file to specific post and/or pages?
- Pass media upload value to input field
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Real time Duplicate title check
- Load custom field value into div with AJAX
- Jquery ajax to custom php file: returning blank data
- jQuery functions only work on homepage
- How can I loop into two different DIVS without repeating the DIVs
- Display notification only once
- Using wp_localize_script to store the template url into a variable to use in JS
- How to add a dynamic javascript snippet to the footer that requires jQuery
- Stumped – Ajax Response Returns 0
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Parsing php string in jquery [closed]
- doing an ajax request always outputs 0
- Using shipped version of jquery
- How to show a dynamic_sidebar if main content content’s height is > a set amount?
- Woocommerce add to cart quantity buttons with AJAX
- combine Code 1 with Code 2
- class click counter save number
- wordpress count link clicks by ip address
- Is there a way to programmatically create multiple pages utilizing the same template but different content from a json file?
- Ajax load more posts with multiple tax query
- WordPress Sending data to Ajax with select option
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- populate form fields in a loop with ajax
- Gravity form built in Captcha
- Click a radio button must set textfield value
- Post repeating with infinite scroll
- Plugins not working on AJAX requests
- How to disable controls in theme customizer?
- JQuery calling a Custom PHP function (Works in Dev but not in WordPress)
- Jquery function working in Dev Console but not otherwise [duplicate]
- How do I Import / Upload Files with jQuery AJAX?
- Why does wp_head hook my functions to the beginning of my source code?
- Automatically set all tags to have a height of 0 if there is no content inside the tag [closed]
- Unset session variable on page reload / setup but exclude AJAX
- Flexslider won’t work on WordPress
- Function won’t run onclick using Ajax
- jQuery Ajax PHP function call returning [object Object]
- How to use the wpsnonce clone post link?
- Removed jQuery script from header.php , any problems?
- Execute Jquery when a specific page in my plugin is loading
- Covert WordPress Blogname into JQuery
- Cloning add_settings_field() with jQuery
- what does $options = get_option(‘test_theme’); do?
- How to load previous or next attachment with jquery ?
- Validating an email input from form field before submit using JQuery, AJAX, and PHP
- How to set value selected using select2 jquery plugin
- Customizer control save then return to default
- Custom html/php/jquery map code in WordPress/elementor?
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Failed to load resource: the server responded with a status of 500 (Internal Server Error) through wp_admin_ajax.php
- How to check a variable Changes
- Ajax filter with loadmore button
- Customize the “Available for back order” text for specific variation
- If user has clicked link add class and store using PHP/WordPress
- Update $wpdb query with AJAX
- AJAX to add to cart multiple products woocommerce
- wp_set_object_terms returns 500 error when called through AJAX function
- How can i send id of the currently posted form data through json response in custom wordpress plugin?
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- How to create an Email Subscription input in WordPress?
- Remove specific javascript when viewing page in Customizer?
- Styling a specific post after hovering over it
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- Remove item from post_meta array via AJAX
- WordPress load javascript file if something… (after the page is loaded)
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- I was wondering if it’s possible to implement card.js on WordPress
- AJAX Filter WHILE Loop not working WordPress
- WordPress 404 when using AJAX to call php function
- wordpress ajax pagination
- Form not working as it should in WordPress, but in a normal HTML site it does
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- AJAX Not Working With WordPress Database properly
- 500 (Internal Server Error) of external php file
- Use jQuery and AJAX to get HTML
- No Authors for custom post type
- Fatal error: Call to a member function get_results() on a non-object in on line 26
- Dynamic Gallery
- What is the best way to get the first few post from WordPress in different divs using a loop?
- Missing items on page
- How to change links in the 3 main categories, on widget category, to a javascript function call
- jQuery vs. $ – Creating jQuery scripts in JavaScript in WordPress using External Libraries
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- Cannot get custom javascript to execute on page
- why my “recepie” category is not taken into account in my request
- Jquery autosave text area after typing
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- Use ajax response in PHP function
- Adding jquery using php function
- How to hide .js files on wordpress website using php or wp plugins or any? [closed]
- notify users when changed database
- getJSON response to PHP
- Upload multiple files via ajax from an HTML file input
- get_post_meta returns on side but it doesn’t return on bottom of admin page
- Translating the “Everything” filter menu in Quicksand jquery file