I’m working on a WordPress Theme (create a custom theme) and using AJAX as pagination for my Custom Posts.
So I’m going to load pages with AJAX but the problem is when I click for next page, instead of next page it’s returning the home page.
Now I’m going to make it easier with a simple sample, if you can help me to call HELLO query in sample below, I will fix the whole codes with your path.
Here is my HELLO target for example (we should call it):
This is my code in functions.php
add_action("wp_ajax_check_user", "check_user");
add_action("wp_ajax_nopriv_check_user", "check_user");
function check_user() {
echo 'hello';
die();
}
And this is my code to call “HELLO” in some page:
$.ajax({
type: 'POST',
url: "<?php echo admin_url('admin-ajax.php') ?>",
data: {
'action': 'check_user'
},
success : function(data) {
alert(data); //FOR DEBUG
}
});
So I can’t call hello and instead I see my home page.
UPDATE:
@face
this is my sample page and you can see the results after click on next page or page 2:
at the bottom of the page please try to go next page or page 2. i made the results as a message box.