Tag Info

Hot answers tagged

2

This will not work due to the "same-origin policy" unless that server you are trying to reach specifically allows these type of requests with something like Access-Control-Allow-Origin: *. You can read the documentation on MDN in order to get more information about this topic. From my tests, the server will also need another header configured namely the ...


2

The problem could be in using admin ajax. If you switch to a different endpoint, the process may speed up. I've used ajax flow on a few sites and you should see a performance gain: https://wordpress.org/support/view/plugin-reviews/ajaxflow Check out some best practices here: https://10up.github.io/Engineering-Best-Practices/php/#libraries


1

Before all of that, I would recommend trying Image Rotation Repair plugin.


1

As suspected, Wordpress was treating the button as type="submit" fixed by doing: <button type="button" onClick="addProperty()">Add property</button>


1

So, you're using wp_localize_script to inject the ajax url. But you didn't use the localized var handle to access that value. Try this: /* ... */ $.ajax({ url: ajaxStuff.ajaxurl, // NOTE use of 'ajaxStuff' object /* ... */


1

when ("#edit").click( is called, the element "#edit" doesn't exist so the .click( cannot be attached solution 1 you call click( juste after .innerHTML = response solution 2 use delegated event like that : $("body").on("click", "#edit", function () {...


1

As you can see, I tried declaring the $post variable as global to account for failures due to being outside of the Loop. The problem is not that the post is "outside of the loop", problem is that AJAX request is a completely separate HTTP request. When you do an AJAX request, is just like you are opening a new window on browser and open the url in ...


1

My suggesion is to use wp_localize_script() to pass the post id to your AJAX calls. Something like this.. function my_script_enqueue() { global $post; $translations = array( 'postID' => $post->ID ); wp_enqueue_script( 'myscript', '/url/to/your/script.js', array('jquery') ); wp_localize_script( 'myscript', 'MyAJAX', ...


1

if the request is from an unauthenticated user, you should use wp_ajax_nopriv_(action) to call the function, which in your case is: add_action('wp_ajax_nopriv_cpm_add_update', array($this,'edit_added_people'));



Only top voted, non community-wiki answers of a minimum length are eligible