AJAX call broken after actualization

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.

Ajax function on #publish only saves as draft – how to make it publish?

Perhaps this solution will work: var flag_ok = false; $(‘#publish’).on(‘click’, function (e) { if ( ! flag_ok ) { e.preventDefault(); var url = shiftajax.ajaxurl; var shift = $(‘#post_ID’).val(); var data = { ‘action’: ‘wpaesm_check_for_schedule_conflicts_before_publish’, ‘shift’: shift, }; $.post(url, data, function (response) { if( response.action == ‘go’ ) { // there aren’t any scheduling conflicts, so … Read more

admin-ajax.php GET custom-post titles

First replace: resgister_post_type with: register_post_type to fix the typo. Secondly replace: while( $portfolio_query->have_post() ){ with while( $portfolio_query->have_posts() ){ where you’ve forgotten the plural s. Note The reason why calling non-existing methods like: $portfolio_query->some_non_existent_method() doesn’t raise a PHP error, is the magic __call method of the WP_Query class: /** * Make private/protected methods readable for backwards … Read more

plugin shortcode not working on ajax request call

…ajax calls can’t show shortcodes because of the admin ajax url that they dont have full access to wordpress enviorment Not true. AJAX calls have exactly the same resources at their disposal as regular WordPress requests. Just make sure to parse the content in the same way the_content() does: $parsed_content = apply_filters( ‘the_content’, $post->post_content ); … Read more

load ajax using admin-ajax.php

The codex says here that The wp_ajax_ hook follows the format “wp_ajax_$youraction”, where $youraction is your AJAX request’s ‘action’ property. I suppose in your js file you should go for: data: { action: ‘lateral_fluid’, // the $action to run }

wp_update_post onclick button using ajax

No no no! Never POST or link directly to a custom PHP file – WordPress won’t be loaded, and to load it manually yourself means making huge assumptions about the file hierarchy. Use the ajax API, which exists specifically for this reason: $.ajax({ url: “<?php echo esc_js( admin_url( ‘admin-ajax.php’ ) ) ?>”, type: “POST”, data: … Read more

Problem with AJAX in wordpress plugin

After Milo’s tutorship: I recommend first reading how to use AJAX in Plugins properly. – Milo yesterday and reading another questions on wp.stack, my problem was solved) Here is an examples of code from my rewritten files 1)get_state.php: ad add_action( ‘wp_ajax_ajax_object’, ‘ajax_handler’ ); add_action( ‘wp_ajax_nopriv_ajax_object’, ‘ajax_handler’ ); function ajax_handler() { global $wpdb, $results, $info, $data, … Read more

Is it safe to use admin-ajax.php in the frontend?

See documentation here but don’t miss the note 2 and the following points : AJAX on the front-end is more complicated, ajaxurl is not defined so you have to call it with wp_localize_script(). you have to use wp_ajax_nopriv_{action} for non logged in users there could be security issue !!! About the third point : Be … Read more