Tag Info

New answers tagged

0

I finally figured this out. What ended up working is putting the script portion in a .js file within the theme directory, calling it using the functions.php in my child theme, and having the HTML input field and div tag in the body of the page. Hopefully this can spare others the same pain I went through.


1

figured it out... The main problem with the scripts so just wrapped them in this for each plugin: function my_enqueue_javascript() { if (is_page('page')) { //Include Javascript library wp_enqueue_script('', plugins_url( '/js/ajax.js' , __FILE__ ) , array( 'jquery' )); // including ajax script in the plugin Myajax.ajaxurl ...


1

You have to localize script by using wp_localize_script function. In the admin side ajaxurl is already available. But in front end you have to localize script to define ajaxurl. Example: wp_enqueue_script( 'custom-ajax-request', '/path/to/settings.js', array( 'jquery' ) ); wp_localize_script( 'custom-ajax-request', 'MyAjax', array( 'ajaxurl' => ...


0

Probably it's because of this: add_action( 'wp_ajax_my_action', 'my_action_callback' ); add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' ); You have to add the action for both hooks. Probably the plugin is hooked to the second hook right now.


0

It might be due to another plugin that affects your website only to logged in users. Try to disable them one by one and see if it works.


1

Ajax endpoint is known to be relatively slow, but that primarily comes from loading WordPress core. If you are seeing drastic difference between two endpoints (native Ajax vs yours custom) that both perform core load, then something is doing something that degrades Ajax endpoint on top of it. I would profile Ajax endpoint to have better idea of what is ...


0

You're removing the current menu item, and current menu page, however your CSS refers to these: .site-navigation li .current_page_item > a, .site-navigation li .current_page_ancestor > a, .site-navigation li .current-menu-item > a, .site-navigation li .current-menu-ancestor > a .current_page_ancestor and .current-menu-ancestor are not handled ...


0

I got the solution for this question. I need to apply there Isotope append method, when adding posts to the frontend. Here is the Isotope append method.


0

This is a bug with the wordpress AJAX trying to update manageedit-pagecolumnshidden on the admin table pages when columns are hidden. It completly breaks the entire admin tables when the table headers are visually hidden. Thanks to Michael Ecklund's clue I was able to figure it out. I created the Ticket here: https://core.trac.wordpress.org/ticket/29030 ...


2

In Wordpress Ajax works this way: First, you register the ajax action and the function you want to use to serve that function, of course, you have to write that function. All the request go to the same URL wp-admin/admin-ajax.php, what it changes is the action, and depending on the action, a different function is called. The function you call, returns the ...


0

I solved my problem after a long time struggling, that's why I think I should list some tips for someone with a problem like this: If you change your javascript file, use ctrl+f5 to force reload the page and the resources. The caching almost got me crazy as I changed the file and the changes didn't take place. Use your browser's network analisys tool. In ...


0

First of all the ajax code in WordPress is different from the normal ajax. Second, you don't add a Javascript into a function, however, it's a better practice to create a JS file and enqueue it. Here is how to do it: JS file: jQuery(document).ready(function($){ $('#input_1_2').change(function(){ jQuery.ajax({ ...


1

The problem is with the element id you are taking. Because if page has multiple ids with the same name (e.g apftitle). Then it will work for the first element only because it search for the first occurrence of id and work for it only You can solve it by keeping the ids dynamic so it will work for all. Or you can use the javascript's this pointer which ...


4

When using Ajax API, and you want to make the ajax callback available for non-logged users, you need to add 2 actions, "wp_ajax_{$action}" and "wp_ajax_nopriv_{$action}". Using only the first action, the callback will be called only for logged users, using only the second it will be called only for non-logged visitors. Try this: function check_username() ...


0

You need to include wp-includes/user.php file when you are using ajax for user related functions. function check_username() { require_once (ABSPATH.'/wp-includes/user.php'); $username = $_POST['user']; if ( username_exists( $username ) ) { $return['user_exists'] = true; } else { $return['user_exists'] = false; } echo ...


2

While Chinmoy's answer is correct I recommand you to use wp_send_json. When doing ajax this is really useful. It hanldes every essential part of the process including security. In real life you can use it like that : wp_send_json_success( $data);//successful requests wp_send_json_error( $data );// errors They return an array with $data encoded in json ...


3

Please change the type type : "GET", to type : "POST",


4

add this before your other add_action call: add_action('wp_ajax_nopriv_zephyr_infinite_scroll', 'zephyr_get_nextpage'); the wp_ajax_ filter runs only when you are logged in. wp_ajax_nopriv_ runs only when logged out. This is so you can separate your requests, and maybe treat them differently, if that's the case. Check wp_ajax_(action)


0

Well, that just won't work for so many reasons if this is actually your whole plugin. I'm guessing you are getting a fatal error here. This is because you are using HTML (and javascript for that matter) in the PHP document. Also, if the getuser.php is not located at the root of your site, JavaScript won't find it. I would also use the jQuery method, as ...


1

Here is what I ended up doing based on @gdaniel's suggestion: AJAX call: $('.btn').click(function() { $.ajax({ url:"<?php bloginfo('template_directory'); ?>/inc/galleries.php", type: 'POST', data: {postID: '<?=$post->ID;?>', galleryCategory: $(this).attr("data-content")}, success: function(resp) { ...


0

because the Heartbeat system is mostly orthogonal to the rest of wordpress and therefor it is not really aware what is the content of the pages it runs on. As it is a relatively new system it probably has edges that are not well defined or tested, and if you think there is some weird behaviour or an actual bug please open a ticket at the wordpress trac - ...


0

Your are pointing to a non existing AJAX file. $.ajax( { // ... url : '/path/myfile.php', // ... } ); WordPress has a predefined file for that: admin_url( 'admin-ajax.php' ) When you are running public queries, then you need to add it to wp_localize_script( 'your-script-handle', 'yourJavaScriptAccessibleObject', array( 'ajaxurl' ...


3

First, like many things in WordPress, it's not like someone decided "let's make this neat and convenient". It was more like someone slapped it together for something, then it got used more in admin, then it got used a lot in admin, then it became kind of practice to use it for non-admin as well. Or something along these lines. Second, it's not as much what ...


1

I have made some changes to your code. See now if this works - function myajax_inputtitleSubmit_func() { // check nonce $nonce = $_POST['nextNonce']; if ( ! wp_verify_nonce( $nonce, 'myajax-next-nonce' ) ) die ( 'Busted!'); $zipcode = $_POST['zip']; // generate the response global $wpdb; $tablename = ...


0

You must first enqueue the script and define the URL. Then you have to create a function for your AJAX callback and add a WordPress action that calls it. Here is a video where I explain it, hope it helps. :) https://www.youtube.com/watch?v=R7OK-TtNuEc


0

You can use get_the_ID(); function to fetch the Id of the current post For more Please visit here



Top 50 recent answers are included