Trying to load content of a post via AJAX
OK I’m trying to load content of a post via AJAX.
OK I’m trying to load content of a post via AJAX.
At the moment I have an ajax that works (I get a success [200] response), but having an issue with the action hooks on the response. The JSON object is not coming back, instead I’m getting a 0.
anyone encountered this bug that it will work when you are logged in but once you log out it won’t work anymore.
Unless I end Ajax processing function by exit() or die(), the Ajax function receives desired and correct output but following by 0.
A nonce is a “number used once” to help protect URLs and forms from
certain types of misuse, malicious or otherwise. WordPress nonces
aren’t numbers, but are a hash made up of numbers and letters. Nor are
they used only once, but have a limited “lifetime” after which they
expire.
Update: I managed to get the AJAX working, but not in the click event. I updated the question to match this.
My ajax call for json data works ok like this
functions.php:
I’ve seen a couple of discussions about getting WordPress to regenerate a unique nonce for subsequent Ajax requests, but for the life of me I can’t actually get WordPress to do it– every time I request what I think should be a new nonce, I get the same nonce back from WordPress. I understand the concept of WP’s nonce_life and even setting it to something else, but that hasn’t helped me.
I’m having an issue creating an ajax search on my single post pages. I need to limit the search results to the custom post types “fod_videos” and “post” and category 12. My issue is the search is returning all the posts under those filters and not taking the search value. I’m guessing I’m missing something obvious but I can’ figure it out. Here’s my setup.
I am relatively new to jQuery and AJAX in particular. I have a small issue with the return value always being 0, though I think this is actually the success message and it’s not returning anything.