Jquery autosave text area after typing

Am not sure what is your ID. Let as assume the ID as example Here is the code jQuery(function($) { $(‘#example’).on(‘keyup’, function() { if(autosave_timer) { clearTimeout(autosave_timer); } autosave_timer = setTimeout(save_by_ajax, 3000); // after 3 second of keyup save_by_ajax function will execute }); function save_by_ajax(){ var mid=$(this).attr(‘data’); var tid=’#’+mid; $(tid).jqte({“status” : false}); var content = $(tid).html(); … Read more

Combo box populating a DIV using ajax/jquery

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 call ajax function to get post info … Read more

How To Pass Ajax Value to PHP Query?

Create simple functions like function func_for_ajax(){ wp_localize_script( ‘ajax_custom_script’, ‘frontendajax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ))); echo “simple demo ajax”; } Than create your ajax pass in wordpress action threw this function name directly. jQuery.ajax({ type: “POST”, action: ‘func_for_ajax’, url: ‘ajaxurl’, success: function(data){ jQuery(‘#content2’).html(data); } });

WooCommerce AJAX cross domain add to cart

If you have enabled the CORS policy headers then you can directly add a product via link given below; Site-url.com/?add-to-cart=PRO-ID&variation_id=ATTR-ID&quantity=1&attribute_YOUR-ATTR-NAME=ATTR-VALUE Trigger this url for an ajax / windows location on an action in your javascript.

send meta box input data without publish button

You can get the post id like this var post_id = $(‘input[name=”post_ID”]’).val(); See this full working code. BTW its only save the value to the meta in the ajax it won’t save it on the publish button you need to add another hook with another function. you can’t use the same function that you used … Read more

using ajax to query sql

See documentation WordPress have admin-ajax.php file in wp-includes/ folder. Put in your data parametr action and create hooks: add_action(‘wp_ajax_{your_action}’, ‘handler’); add_action(‘wp_ajax_nopriv_{your_action}’, ‘handler’); ajax.url parametr you can get by using wp_localize_script(‘YOUR SCRIPT handle’, ‘ajax’, array(‘url’=> admin_url(‘admin-ajax.php’))) All code must looks like: add_action( ‘wp_enqueue_scripts’, ‘callback_for_setting_up_scripts’ ); function callback_for_setting_up_scripts() { wp_register_style( ‘mein-plugin’, plugins_url( ‘style.css’, __FILE__ ) ); wp_enqueue_style( … Read more

Load Meta box value into div AJAX [duplicate]

Add data attribute data-post-id for the post id. Eg. HTML: <ul> <li><button class=”play_next” data-meta-key=”url-1″ data-post-id=”<?php the_ID(); ?>”>Video 1</button></li> … </ul> Missing data attributes in js. $( this ).data( ‘metaKey’ ); should be $( this ).data( ‘meta-key’ ); and $( this ).data( ‘post_id’ ); should be $( this ).data( ‘post-id’ ); E.g. Jquery: jQuery( document ).ready( … Read more

what’s the way to access variables from serializeArray

You should be getting the data from the $_POST server variable, not the $_REQUEST eg. (isset($_POST)) { $postData = $_POST[‘post_data’]; } $_REQUEST doesn’t force you to figure out if the variable came from GET, POST, COOKIES, etc. It’s useful for debugging scripts or when the variable might come form one of several sources. For instance … Read more