Tag Info

New answers tagged

-1

You have to add jquery.form.min.js it work for me , Hope it works for you.


1

The main issue I was having is that when an ajax request hits not all hooks are being loaded. I used this code: $return = array(); foreach( $GLOBALS['wp_actions'] as $action => $count ) { $return["message"] .= $action . ", "; } wp_send_json($return); This showed me the hooks that were running before and I got it to work. I think removing ajax ...


2

OK, I found out that my DB encoding was LATIN2 and wordpress forced UTF-8 in all calls after the update. When I changed my database's encoding to UTF-8 it all started to work. I also used: $comment = mb_convert_encoding($comment, "UTF-8"); just to be shure.


2

There is always a timeout, be it TCP or the PHP execution time ( unless you configure your server in a weird way, PHP will kill long running tasks ). If you need to do a lot of work you should: Break it into smaller pieces Plugins like regen thumbnails retrieve a list of items to do work on, then go through the list in small fast batches keeping track of ...


0

Open the website with Web Developer tools or Browser inspection tools ( Firebug )etc and then Run "Console". Refresh your website and see the Ajax calls. Check the POST window in Ajax call to see action script. That'd tell you the exact function being called.


1

I am not sure the output you have provided is the correct one but do you notice the '0' character at the end of your string? ...


0

If you're releasing this as a plugin, you absolutely must use the AJAX API. It's super easy: /** * Handle the request and return the result. */ function alumni_process_request() { global $wpdb; // All your processing code from your original question, except for loading WordPress! return $data; } /** * AJAX handler for the "alumni" action. ...


0

I'm a bit confused - why the two submit buttons? And you're outputting the same id multiple times (inside a foreach loop), which will choke jQuery. Try the following, using classes: $form = ''; foreach ( $results as $result ) { $value = esc_attr( $result->aid ); $form .= '<form method="post" class="aid-form">'; $form .= "<input ...


2

When you send an AJAX request, wp-admin/admin-ajax.php is called, not your template file. This separate request has no knowledge of all existing code in all existing templates, because they aren’t even included. What is included: the theme’s functions.php and plugin files. This is why your callback works in a plugin. As a rule of thumb: templates should ...


0

thanks alot @Antonie Guillien, it solved :D var $j = jQuery; function testClick(){ alert('Button Clicked'); } $j(document).ready(function() { /*$j('.my-button').click(function(){ alert('Button Clicked'); })*/ })


0

The only way I could accomplish this is by using the wp_localize_script function. The function is quite straightforward and lets you simply send anything from server side to your script. This also outputs the variables inline, but this is the best WordPress allowd in this situation.


0

Try to apply some function like htmlspecialchars() on your query before searching for it, it will translate your special chars into HTML entities.


0

One thing you could do is set a variable in the archive.php like <script>var isArchive = true;</script>. Or in any template do if (is_archive()) { /* set the variable */ }. And then in the JS file do if (typeof isArchive != 'undefined') { } but there are probably way more elegant solutions that I'm unaware of. This also probably assumes you ...


0

This code worked for me in WordPress: add_filter( 'authenticate','one_session_per_user', 30, 3 ); function one_session_per_user( $user, $username, $password ) { $sessions = WP_Session_Tokens::get_instance( $user->ID ); $all_sessions = $sessions->get_all(); if ( count($all_sessions) ) { $login_page = home_url( ...


1

What a type you work with response If you work with json $.post( ajaxurl , data , function(res){ // your code },'json'); Remove wp_die() and replace with die()


0

To load your single.php template, first you need to move your functions.php code <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <div class="entry-content"> <?php the_content(); ?> </div> ...


1

Your button was added dynamically. So you can not bind event in simple way. As button is added after DOM is fully ready. You need to bind it with the refrence of document or body jQuery(document).on('click', '#readmore', function(e){ e.preventDefault(); alert("you clicked the button"); jQuery("#bodytext").css("display", "block"); }); Read ...


0

You're not handling the names the same way as the other fields: //// VERIFIES CREDENTIALS $username = isset($_POST['username']) ? trim($_POST['username']) : ''; $first_name = isset($fields['user_first_name']) ? sanitize_text_field(trim($fields['user_first_name'])) : ''; $last_name = isset($fields['user_last_name']) ? ...


0

Ok, As it's front-end... I might: Set up the folder on the server so that WordPress can read/write (775 or 755 ordinarily works depending on how your server is configured in terms of user/group permissions). Allow a user on the front end to see the files or choose which file to delete Upon choosing the file, pass the parameter to an intermediary PHP ...


2

Your attempt to send your AJAX requests to wp-admin/admin-ajax.php is correct but it will be better to create a javascript global variable using wp_localize_script() to make any data available to your script in functions.php that you can normally only get from the server side of WordPress. For example, your javascript code can be in the same folder with ...


-1

You cannot use Ajax on Wordpress that way. There are many tutorial about using Ajax on wordpress. I think the simplest is http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/



Top 50 recent answers are included