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
- Using Ajax with a Class file
- SSL breaks customizer: page isn’t returned from ajax
- Stop admin-ajax?
- How to verify nonce from Bulk/Quick Edit in save_post?
- Get attachment ID of author_meta image – Attachment Metadata
- store/cache ajax sent data to avoid repeated request
- How to implement AJAX post navigation into WordPress?
- wp_ajax_[service] returning 0
- Trying to load content of a post via AJAX
- Insert Post using Ajax
- How can I automatically login using a URL?
- Run again current query via ajax but changing a var
- 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
- How to make ajax content indexable by search engines?
- Ajax requests with different WordPress Address and Site Address setup
- Conditional action hooks
- Buddypress ajax problem after adding new groups sub nav [closed]
- Allow AJAX call to other roles than admin
- How to check username availability with ajax at registration
- submitting form via admin-ajax.php returns 0
- Help add ajax load more button
- Can a wp_nonce created from domain 1 to be verified on domain 2?
- admin-ajax.php slow, how to speed it up?
- How to use several wp_ajax_ functions for different queries?
- Three level taxonomy dropdown frontend
- I’m getting a 401 while calling the wp-json endpoint via ajax
- Unable to parse JSON response from wp_send_json_success [closed]
- How to solve “Updating failed” with 403 Error when trying to save a Site or Post in Gutenberg?
- problem with WordPress ajax
- How to make tabulator ajax call in wordpress?
- How would you update a frontend form with AJAX
- Updating User Meta with Array on Click of Button AJAX
- Why is on status span no search results?
- eventON plugin AJAX call triggers website crash
- 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
- “Loadmore” button is not working in buddypress [closed]
- Uncaught ReferenceError: the_ajax_script is not defined . How is this not defined?
- Right way to include blog-header.php?
- AJAX action through direct link
- Ajax call on new site with jupiterx theme getting 400 response [closed]
- I can’t get a return value from Ajax
- WordPress AJAX return 0 – My case
- Creating an auto result search bar
- update_option is not saving an array, but saving the string ‘Array’
- Upload data from weather station to WordPress Website
- Need help with ajax
- Using nonce when loading posts with AJAX
- What WP-API authentication method should I use to interact with anonymous / not-logged visitors?
- Get title and featured image using Ajax
- My function containing a mysql query launched by ajax is not working in wordpress. What am I missing?
- Updating Jquery object with newly created elements after AJAX call
- Wp admin ajax load more
- wordpress ajax search posts
- Ajax call from Plugin using Class
- Ajax by worpdress affects called jquery inside template file
- AJAX form not working, still reloads on submit
- Call public static method from ajax ‘wpcf7_mail_sent’ hook
- Update user meta via ajax from frontend, saving issue
- How to get the admin page slug using wp_loaded hook?
- Having a self updating list
- First time doing Ajax with WP, how to do it?
- Unexpected WordPress search results
- WordPress Get Header and Footer using in Admin Area
- Tie the sending of an ajax request to WordPress hooks
- AJAX: admin-ajax.php is adding extra content to my script’s response – how to exclude header, footer, etc.?
- Is custom behaviour possible when asynchronously uploading?
- ajax page template
- apply_filters, EMBEDS and AJAX not a friends? [duplicate]
- Using Javascript Callback from plugin in a theme
- Why does my Ajax Get request give a 400 bad request?
- How to get data with Select AJAX PHP
- Add “load more” functionality to an AJAX response
- weird Internal Server Error – no error log produced
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?
- Successful ajax call returns lots of whitespace and text of code with 0
- How to submit a button automatically after every scheduled hours?