Ok, so it’s pretty easy error – just a typo 😉
You use this line to localize your script:
wp_localize_script( 'ajax-script', 'my_foobar_client', array(
'ajax_url' => admin_url( 'admin-ajax.php' ), 'we_value' => 1234 ) );
So you use ajax_url
field to store url to admin-ajax.php
But you use this line in your js file:
my_foobar_client.ajaxurl,
and there is no ajaxurl
field in that object. It should be ajax_url
And here’s another typo:
$('button').click(function(){
As far as I can see, there is no button in your form. There is input of type submit with class button
, so it should be:
$('.button').click(function(){
Also you’re not preventing default behavior after the click, so your form will still cause reload… This will solve that:
$('.button').click(function(e){
e.preventDefault();
...
Related Posts:
- How to handle WordPress Plugin Front-end AJAX Call [duplicate]
- How to do the simplest possible frontend ajax call from a plugin?
- Convert to shortcode?
- How to request admin-ajax.php correctly when wordpress URL and site URL are different?
- AJAX doesn’t pass variables to the php function in the plugin
- What’s the preferred method of writing AJAX-enabled plugins?
- Handling jQuery Component Collision
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Ajax Load More and Masonry: is it possible to load admin-ajax.php in the front end?
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- ‘Lazy loading’ list of posts with pagination
- How to include admin-ajax when loading external javascript
- Restrict backend but allow to use post.php?action=delete&post=POSTID from front-end
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- How can I process xml file on upload?
- Handling jQuery Component Collision
- ajax front-end increment views on click
- Check if email address exists front end with AJAX in a plugin
- WooCommerce get_price returning wrong price when used via ajax
- Preview featured image using frontend post plugin
- How to add a full edit link to front-end editor?
- How to Create a Custom Panel and Fields in Post Page [Plugin]
- AJAX search posts and pages
- Theme is Causing Ajax Conflicts for a plugin I cant identify it
- wordpress, search form using ajax
- Search for categories
- Best place for if/else piece of code related to custom plugin?
- WordPress Integration with Google Groups
- Best place to load wp_ajax_the_ajax_hook action in plugin
- jQuery.post not working within shortcode – WordPress Ajax
- How can I inject options into an select tag inside the widget form?
- Init plugin again after ajax call finish
- Display wordpress post’s in popup?
- Using color picker in plugin, does input attribute order matter?
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- How to call plugin functions in a custom template
- AJAX call – failling to call do_action
- What are the Best Practises When Using AJAX in Plugin Development?
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Does having more than 30 Admin Ajax affects site performance (plugin)?
- Submit Form data to another page via Ajax (WordPress Way)
- Front-end CSS Library for plugin [closed]
- How to display checked posts on another page over AJAX? (like comparasion style)
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- where do I send my ajax calls
- Ajax save data to database on document ready, no data being saved
- don’t call ajax if not plugin page
- How to get specific string/value from an array? php [closed]
- woocommerce search by sku and title ajax
- Where Should i write the code for wordpress ajax voting?
- Disable submit button order
- Passing PHP Variables to AJAX Loaded Pages
- Generate Own Custom CSS Button with icon
- Call ajax on the frontend
- How to auto strip hyperlinks & images in wordpress post
- Create a link which allows visitors to disable a plugin?
- Ajax request sends url rather than data
- grab or load text on demand
- best way to run a php script away from the template?
- admin-ajax.php 500 error when new users try to register
- Send Array from JS to php file then insert it in wp database through a plugin
- wc_get_template_part doesnt display the content [duplicate]
- Upload PlugIn Button is missing
- In a plugin, How to update a json file using ajax
- Cannot pass value variable to WP AJAX functions
- JS working when used normally but not in wordpress
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- How to avoid the 403 Forbidden error in a WP Plugin with Ajax and PHP
- Conditionally load public and admin code with AJAX working on both sides
- How to fix blog article view and share #’s?
- How to disable/enable PHP plugin functionality based on a TinyMCE toggle-button
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Add Cancel Button to a Custom Meta Box
- Get shortcode attribute for AJAX call
- ajax voting for custom post type
- Why can’t I call a function from inside my registered AJAX function?
- WordPress environment not loading properly
- ‘Easy Template Path Hints’ for WordPress?
- “Listen” button on my main post page
- Why doesn’t a form need an ‘action’ with a plugin that uses the post data?
- WordPress Feedback popup with date saved into table
- Add Flatr button to Sharing option
- WordPress Settings – Custom Button actions
- Javascript not working
- Ajax specific template not loading in replacement of index.php
- WordPress ajax not working in registration
- Ajax return 0 in plugin – ajax only used in wp-admin
- ajax request not returning the result
- How do I convince this button to do something when it is clicked?
- Working on fixing wp-front-end-editor, encountering undefined index
- My AJAX API plugin isn’t working
- ajax sends data to plugin
- WordPress User Frontend Editing Custom Fields
- Help me with my first very basic plugin
- Jquery post responses 500 error after some time and lastly an 503 error
- Ajax button “Load more” is not loading correct language version posts for logged out users
- Select posts from list and add them in a new list
- Display Any Field fromAdmin Panel in Frontend via Shortcode?