Your Javascript is loading the whole page anyway, since you are sending a request to the_permalink
. If you are going to do that just reload the page.
First, your should be using the AJAX API. There are a couple of steps but it isn’t that hard. See the Codex to get started.
In your callback you only want to run the line that gets the $pages
variable and then whatever processing is necessary to format your results. Return that formatted content as a string. Then use your jQuery to replace the apprpriate part of the page with the new content. There are several jQuery functions for doing that.
Related Posts:
- Refresh HTML Page in Browser Automatically on Timer – Every 15 Min
- How to load wp_editor() through AJAX/jQuery
- Open a Thickbox with content trough AJAX
- Is there a JavaScript API? How to access public and private data in JS?
- failed to load wp-admin/admin-ajax.php
- Are ‘wp_ajax’ and ‘wp_ajax_nopriv’ exclusive to authenticated and non-authenticated users?
- How to HTML5 FormData Ajax
- Get posts with ajax
- Ajax requests without JQuery
- WordPress AJAX Login Screen
- Custom PHP endpoint for a plugin’s AJAX call
- How to link WordPress heartbeat to ajax form
- How can I get logged in user’s session data from admin-ajax?
- WordPress Ajax Login without page reload
- Custom ordering fails after AJAX post filter
- How to securely add an Ajax button to a WP Admin page?
- How to “Load More” posts via AJAX?
- Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php
- Prevent page reload after ajax form submission
- WordPress Ajax Getting Response “Null”
- admin-ajax return error 400 for Chrome/Edge but not Firefox
- Is it safe to manually sign a user in using AJAX?
- WordPress Admin AJAX Serialize
- My ajax code not returning ajax value
- register ajax calls hook
- Why a strange discrepency between get_current_user_id() when using AJAX versus output of document.cookie?
- Loading post template that contains a nested loop with ajax
- Long Polling: Stuck in while loop
- Show Post Content with AJAX
- Admin-Ajax Error
- Customizer AJAX using buttons
- WordPress Ajaxify Problem with Scroll-to [closed]
- Can’t trigger an AJAX function with a submit button in the dashboard
- AJAX Call is Only Returning 100 Results from Query
- AJAX and -1 response
- How to make custom button link on the WordPress Admin Bar run by AJAX
- Ways to load admin-ajax faster without initializing all plugins?
- is_single() conditional check inside ajax php function
- How to make registration form ajax?
- Specify ABSPATH in jQuery url
- WordPress action – Pass arguments into action in an AJAX call?
- 403 error When i send ajax request on WordPress website
- Ajax Call 400 Bad Request error with POST request but not with GET request
- While Ajax is working well, media upload isn’t showing the imagines
- How can I call an api before user login
- Problems with wordpress nonces in Ajax call
- Get post content and show it in a div
- Output multi-steps form results in same page
- Full Front End, AJAX comment system and comment reply script
- why does not work ajax that add_action registered in wordpress
- How to get post from pure frontend AJAX (using only post ID)?
- Auto load subcategories content with ajax
- Multiple AJAX requests using the same ajax_object.ajaxurl
- Is there a better way to access transients using javascript
- Ajax not working for certain user roles
- Filter custom post types by custom field using AJAX
- How to perform a frontend HTTP call with AJAX when plugin save the new settings?
- Refresh loop of custom posts (div) after new post is published
- Use ajax request to load sidebar
- Problem loading ajax in the header
- How to detect if the ajax_query_attachments_args was triggered to set the featured image?
- WordPress ajax response save into database
- Updating failed. The response is not a valid JSON response. specific to my browser when I include javascript in my html
- Automatically refresh div id every 15 seconds with code snippet from .php file
- Zip Files from custom fields
- Prevent AJAX caching from plugin
- Ajax call returning 0 in page template
- If I leave out the wp_die() in the testiframe function I get the ‘0’ appended to my output. If I put it in, the page w/ iframe linked to it crashes
- how to make sure js is enabled before executing php function
- How to run an ajax call in elementor editor
- ERROR while passing data from JS to PHP via AJAX
- 400 Bad Request – Post to admin-ajax.php
- ajax load more instead of pagination
- jQuery AJAX url wit variable
- Using existing ajax data that is loaded into page
- Ajax call works for logged in users and returns “Bad Request” for guests [duplicate]
- On form submitting, admin-ajax.php shows status as pending
- Ajax WordPress pass post URLs
- Should I edit a user meta field with PUT, PATCH, or POST and WP::Editable
- AJAX action returning empty posts array?
- Infinite Scroll
- Cannot add multiple single images at once
- How to send custom variable in Media Uploader ajax request?
- WordPress Ajax JSON success return no being recognized
- Session variables lost during Ajax calls – WordPress – Sage Starter Theme
- WordPress page content only in fancybox except direct click
- Ajax takes 10x as long as it should/could
- While doing ajax, WordPress returning internal server error 500 and stating that my theme functions are undefined
- How to use AJAX to check if user is still logged-in?
- Ajax navigation and scripts loaded only on certain pages
- Closing ajax function file with die() causes error and empty page
- How to load wordpress sidebar using AJAX [duplicate]
- WordPress Pagination with ajax – Dots
- Bad Request when adding new post via ajax form
- How To Pass Ajax Value to PHP Query?
- Ajax load more posts button
- PHP cookie not set within AJAX call
- WordPress Ajax send response on every iteration of a loop
- Access to a data from a response AJAX called in a template file php
- Escaping admin_url output being passed to js (esc_js vs esc_url)