New answers tagged

1

You can try to use new FormData() instead of new FormData($('form#change-avatar')[0]). Also, after processData:false you should add contentType: false since jQuery will set it incorrectly otherwise, and for url, instead of ajaxurl you should useajaxobject.ajaxurl, since with wp_localize_script, the second parameter is the javascript object name


1

It might be the case that you are using you JS validation before enqueuing this script. You code may be like.. <html> $("#myForm").validate(); or JS file that uses validate() jquery.validate.js here </html> Above code is just for demonstrating. So you are using validate() function before it has been enqueued so it is throwing ...


0

First, I would make sure the update_avatar() function can read the form data. Maybe the function needs to accept an object? Like the form or even the event... Second, I think you need to specify in your data an "action". This is the name of the ajax function that processes the data being sent. In other words, the target of the ajax call. In your case, it ...


0

You need to create separate tables for store sticky notes and save user sticky notes to that tables , in this way you can manage multiple sticky notes of user. i think this idea will help you.


0

The reason for the media uploader not opening when clicking the second button is that both of your buttons have the same ID, which you are also binding to the function that open your uploader. Element IDs should always be unique, hence the .click function listener will only detect when user clicks the first button (=first one with id="image-url"). To solve ...


0

this not perfect way to write inline java script , write java script into document ready event jQuerydocument ).ready(function() { jQuery( ".wc-proceed-to-checkout" ).css("display", "none"); });


0

Decided to go a different route. For whatever reason couldn't get the Headroom.js to add CSS classes to the target in Wordpress, worked fine in plain HTML but wouldn't register with Wordpress. Still unsure if it has anything to do with how I enqueued the scripts but everything else works so unsure. Decided to remove the plugin and use a custom built JS ...


0

Changing img: obj_test.stylesheet_directory_uri + '/img/ajax-loader.gif', to img: "http:// urltoimage .com/test.gif", solve the problem. Important - the url between '...' does not work! The url must be between "..." That was the problem i dont figured out before :)


0

Without knowing how you're populating your combo box, here's how I would do it: Use jQuery to capture the form selection: jQuery('#formElementID').change(function () {//this captures dropdown menu change event //call js function and pass form value - in my case a post id fetchTenantWoContactInfo(jQuery('#formElementID').val()); }); Use function to ...


0

You are using css to display none we don't need to use show() function. Please click on javascript icon in fiddle and select any jquery1.9.1 or above version . Update this code and run ( http://screenshotlink.ru/8f491216a33e437f762eb8815efec77d.png ) $(document).ready(function(){ $('.share-icon').on('click',function (e) { var id = $(this)....


0

For the future: Questions like this should be asked on Stack Overflow. As you expected, AJAX would be a good choice to use. Let's make a new file called send-email.php <?php $to = $_POST['email']; $subject = 'A teacher wants to know your relief work status'; $message = ' <img src="http://xyz.com.au/wp-content/uploads/xyz-logo-800.jpg" ...


0

Please add the id attribute in anchor tag please see this working code with jQuery.. foreach ($comments as $comment) { <a class="respond-to-messages" id="<?php echo $comment->comment_ID; ?>" href="#<?php echo $comment->comment_ID; ?>">Reply to message</a> <div id="comment-<?php echo $comment->comment_ID; ?>" ...


0

You don't need to move your wp_localize_script anywhere else. Your problem lies within the fact that you try to use AJAX outside of WordPress. Let me refer to an earlier answer of me showing a simple version of how to use AJAX in WordPress here


0

Here's a slightly different way of doing it, replacing the existing enqueued script with the CDN and adding a fallback. Also matches to your existing jQuery version in WordPress. Found it pretty reliable in practice: add_action('wp_enqueue_scripts','jquery_cdn_with_fallback'); function jquery_cdn_with_fallback() { global $wp_version; // get the ...


0

Add your fallback code into a plugin and save your plugin in the MU folder: http://codex.wordpress.org/Must_Use_Plugins. Then this will run before any other plugins


0

You can apply your code on certain page by using is_page() function like this if(is_page('type_page_slug_here')){ /* Your script will go here */ } You can also use page ID instead of page slug. Use this code in functions.php.


2

You cannot use wp_localize_script in page template. You have to use it in functions.php or your custom plugin, after you register your script, which is usually in the wp_enqueue_scripts action. https://codex.wordpress.org/Function_Reference/wp_localize_script


0

I believe you're asking how to call .slideToggle() only on the commenting form specific to each comment. Is that correct? If so, you can use the .next() function in jQuery to get the element immediately following the link that was clicked. var $reply_form = $(this).next(); $reply_form.slideToggle(function(){ if($reply_form.height() > 0) { $('...


0

Check your javascript console for errors. You can't use $ in WordPress. Replace it with jQuery everywhere but jQuery(function ($).


1

The following is the solution I came up with: <div id="selection1"> <div id="dropdown1"> <form id="choice1" action="<?php bloginfo('url'); ?>" method="get"> <?php $select = wp_dropdown_pages( array( 'post_type' => 'page', '...


-1

wp_send_json( $result ); if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { wp_die(); } UPD The besat way to use ajax requests with wp is to use wp native ajax actions add_action( 'wp_ajax_my_action', 'my_action_callback' ); add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' ); https://codex.wordpress.org/AJAX_in_Plugins so you ...


2

How can i return a PHP value from a WordPress page to a JQuery function? Use wp_localize_script to create an object and pass it to the JavaScript.



Top 50 recent answers are included