How to jQuery Ajax show new data from successful insert?

Modify your code as follows: add_action(‘wp_ajax_send_projectmessage’, ‘send_projectmessage’); function send_projectmessage() { global $wpdb; $wpdb->insert( //insert stuff to db table)); // Call your function to retrieve your data and send it to browser $messages = load_projectmessages($projectid); wp_send_json_success($messages); } Display data through JS by modifying this ajaxRequest.done(function(data) { console.log(data); }); to this ajaxRequest.done(function(data) { // Put markup for … Read more

underscore template dynamically remove row Jquery

This isn’t WP related but Its not working because you are trying to add an event to a dynamically created element. Replace… jQuery( ‘.remove_field’ ).on(“click”, function(e){ e.preventDefault(); jQuery(this).parent(‘div’).remove(); }); With jQuery( ‘body’ ).on(“click”, ‘.remove_field’, function(e){ e.preventDefault(); jQuery(this).parent(‘div’).remove(); }); You can read more about your issue here.

Accessing javascript in multiple files [closed]

You have to create a dependency with wp_register_script($handle, $src, $dependency, $version, true/false); See WP codex: wp_register_script and then make sure that the second file is loaded correctly and right after the initial script. The third parameter is an array for dependencies/other “handles”. So..in your case: <?php // Functions.php or somewhere else wp_register_script(‘my_first_script’,get_template_directory_uri().’/js/my-first-script.js’, array(‘jQuery’), ‘1.0’, true); … Read more

A $_POST should occur when submit form but is not?

Add this to functions.php add_action(‘wp_ajax_post_language’,’post_language’); and then make either of following changes in your code. Because your jquery code is sending FirstNM to server (not FirstName). Therefore in post_language() function, change this line $FirstName = isset( $_POST[‘FirstName’] ) ? $_POST[‘FirstName’] : ”; to $FirstName = isset( $_POST[‘FirstNM’] ) ? $_POST[‘FirstNM’] : ”; OR Change ‘FirstNM’: … Read more

Insert Into Post Not Working For Audio File Using jQuery

I have come up with better and new working version that supports all file types which I am going to share here in case anyone else is looking for this answer. Input field added to metabox <input type=”text” name=”sermon_mp4″ id=”sermon_mp4″ value=”<?php echo $sermonmp4; ?>”/> <input type=”button” id=”sermon_mp4_button” value=”Add Sermon Audio” /> jQuery <script type = … Read more

How to keep HTML form field that is conditional hidden with javasript hidden after page reload?

Try this code: // Conditionally show price (function ($) { window.onload = function() { if ($(“#select_price_option”).val() == “I need more information”) { $(‘#price_input_div’).hide(); } $(“#select_price_option”).change(function() { if ($(this).val() == “I need more information”) { $(‘#price_input_div’).hide(); } else { $(‘#price_input_div’).show(); } }); }})(jQuery);