Need help with Access-Control-Allow-Origin

I found !!! It had nothing to do with “Access-Control-Allow-Origin” was because of the API key, I entered the username and password from my dashboard help scout, I had to enter the api key for my documentation 🙂 Thanks a lot for your help 🙂

How to get setting from separate file?

Simple answer: Don’t add a separate PHP file for AJAX requests. Declare the functions that will be used in your plugin and load them via admin-ajax.php. add_action(‘wp_ajax_custom_action_name’,’custom_action_handler’); // to make AJAX action available for non-logged in users: add_action(‘wp_ajax_nopriv_custom_action_name’,’custom_action_handler’); function custom_action_handler() { global $wpdb; // optionally keep the actual functions separately // include(dirname(__FILE__).’/ajax-handler.php’); // custom_ajax_handler_process(); // … Read more

Redirect after saving form; and yet use wp_die()

Simply, you can not redirect the user from the sever in a Ajax callback. The redirect in the Ajax callback redirecta the Ajax request itself, it doesn’t redirect the user to a new location. I hope you understand what I mean. Remember that Ajax, by definition, is asynchronous. So, you need to think in another … Read more

Using get_theme_mod in php ajax form doesn’t work

You should never access directly theme files, form submissions, ajax, and even just get requests will be blocked at the server level by some security hardening measure. Ignoring that for a moment, the reason your code fails is because wordpress wasn’t bootstrapped and therefor there are no core functions available. It is actually not 100% … Read more

Load image src through Ajax by ID?

You would be better off preloading all the images for the current page ahead of actually outputting them. Then you reduce the queries from n*2 (there are actually two database queries per get image call, one from the wp_posts table, the other from wp_postmeta) down to just two. $images = []; foreach ( $pages as … Read more

wp ajax execution time aborted 30 sec

there is a property timeout for ajax and you can use it. jQuery.ajax({ url: admin_ajax_url, error: function(){ // will fire when timeout is reached }, success: function( response ){ //do something }, timeout: 3000 // sets timeout to 3 seconds });

Using nonce when loading posts with AJAX

GET puts all your params on the URL like; http://example.com/thing?foo=bar&x=y For POST you could include all that information but it won’t show in the URL. http://example.com/thing Obviously if you’re thinking about security, using POST is more ideal because your params won’t show in access logs or accidentally picked up by search engines or whatever. Sending … Read more

WP_query offset seems to be counting draft post – AJAX load more

There is a argument for posts query is post_status. It’s values are like below- $args[‘post_status’] => array( //(string / array) – use post status. Retrieves posts by Post Status, default value i’publish’. ‘publish’, // – a published post or page. ‘pending’, // – post is pending review. ‘draft’, // – a post in draft status. … Read more

ajax refresh to display new posts

Try this guide to write an ajax request for your homepage. It’s plenty self explanatory. Then, using jQuery, make request to the website every 30 seconds or so. There is no way to notify a client about a post being published, the client itself has to check whether there is a new post published or … Read more

WordPress Ajax Filter

In the way you are using wp_localize_script(), the object’s name is filters, not reports; so, in filter.js you should use filters.ajax_filter. Also, you should define the variable options before use it. $( document ).ready(function() { $(“input:checkbox”).on( “change”, function() { console.log($(‘input[name=”filter[]”]:checked’).serialize()); jQuery.ajax({ url : filters.ajax_filter, type : ‘post’, data : { action : ‘filter_reports’, // You … Read more