The problem is with the AJAX endpoint URL, i.e. url: userimg.ajax_url
, which is not actually defined in your JS/PHP code.
More specifically, you did define the correct URL, but in the JS object, the property name is ajaxurl
and not ajax_url
:
// wrapped for brevity
wp_localize_script( 'ajax-account', 'userimg', array(
'ajaxurl' => admin_url( 'admin-ajax.php', 'relataive' )
));
So in your $.ajax()
args, just make sure you use the correct property name — ajaxurl
. Or change the one in your PHP to ajax_url
.
And then the problem would be gone.
Related Posts:
- Load minimum WordPress environment
- admin-ajax.php returns 0. How do I debug it and fix it?
- How to allow to user non logged in WP system upload in media library?
- Using wp_handle_upload and media_handle_sideload with ajax
- How to know what page is calling admin-ajax.php?
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- Ajax image upload with media_handle_upload and form.js
- wp_handle_upload returns empty error array
- Pass additional parameter with async upload
- How to disable drag-and-drop upload function in Media Library?
- Distinguish between 2 instances of admin-ajax.php
- Why is the file not uploading to the server?
- Frontend AJAX Media Upload returning 404
- How to require files in a custom endpoint
- Cannot add multiple single images at once
- How to send custom variable in Media Uploader ajax request?
- wp_enqueue_media problem
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- SSL breaks customizer: page isn’t returned from ajax
- Using Nonces for AJAX that only retrieves data
- How to verify nonce from Bulk/Quick Edit in save_post?
- How to implement AJAX post navigation into WordPress?
- wp_ajax_[service] returning 0
- Trying to load content of a post via AJAX
- Ajax function returns -1
- Problems with creating sortable sections in customizer
- Is it OK to use a system cron to trigger a function hooked into the AJAX API
- Filter WP user acf field by ajax
- Ajax Request not coming back to class
- fetching via fetch/ajax gutenberg block data from third party
- How to make ajax content indexable by search engines?
- Conditional action hooks
- Buddypress ajax problem after adding new groups sub nav [closed]
- How to check username availability with ajax at registration
- Conditional success callback based on Ajax Response not working
- admin-ajax.php slow, how to speed it up?
- How to use several wp_ajax_ functions for different queries?
- I’m getting a 401 while calling the wp-json endpoint via ajax
- Unable to parse JSON response from wp_send_json_success [closed]
- problem with WordPress ajax
- Ajax simple experiment
- How to make tabulator ajax call in wordpress?
- How would you update a frontend form with AJAX
- Radio buttons live refresh in the customizer
- Admin ajax add tag callback
- Stop auto load wp-admin admin-ajax.php
- wp_enqueue_script() doesn’t work with AJAX
- Dynamically add more fields/remove last field in a form
- Ajax Request for both logged and non logged users
- How do I Import / Upload Files with jQuery AJAX?
- AJAX call inside plugin class not triggering
- WordPress Heartbeat API cannot parse data
- Cache plugins and ajax nonce verification
- Ajax function on #publish only saves as draft – how to make it publish?
- AJAX call broken after actualization
- WP_Ajax Hook doesn’t execute this PHP code
- Ajax function not returning any results
- post values to custom post type which has advanced custom fields
- ajax problem – function on server is not called
- wp_mail doesn’t work when logged in?
- How to continuously send feedback via AJAX responses to my client?
- Need help with Access-Control-Allow-Origin
- Send email via ajax
- wp_ajax handler with multiple class instances
- admin-ajax.php (aborted) error when using jQuery.get
- Storing temporary data for a custom post type
- Load page HTML content through AJAX
- Not getting an ajax readystatechange on my page
- Allow users to upload multiple images to their profile
- Display full WordPress post under search form using AJAX
- Ajax callback not work
- WordPress Select Option Load Custom Fields
- Add ajax to plugin in admin area
- Search live Ajax
- jQuery.post returns 0
- Ajax login fails: script sets cookies, but is_user_logged_in() returns false
- Using wp_send_json_success instead of $result[‘message’], die, etc
- admin-ajax error 400
- wordpress admin ajax trash_comment
- Ajax call on class returns old data
- how to correctly use json_encode with ajax
- delete post meta data in array WordPress
- How to trigger lost password email using REST API?
- Display post thumbnail after clicking on post id with AJAX
- How to block search engines indexing certain AJAX actions
- Error while submitting form using AJAX and php
- How to fetch meta_value and meta_key in matrix after ajax request by post_id
- wp_ajax_action, wp_ajax_nopriv_action not working
- Manually cache a special, non-WP-but-using-WP page (e.g. Ajax results) with W3TC
- Is it a good idea to init ajax functions only while ‘DOING_AJAX’
- register_setting and AJAX?
- ajax response is 0 instead of ‘script’ [duplicate]
- using ajax to query sql
- A refreshless WordPress website
- get_template_part() does not render after the ajax request
- $wpdb Ajax not redirecting to main page
- how reduce fetch/XHR response time
- Custom WP rest api endpoint only working on non https?