Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question already has an answer here:

I am currently working on a single page website. I am trying to retrieve the page content via AJAX.

The page URL is http://mylocalserver/sad/wp/clients.

    $.get( 'http://mylocalserver/sad/wp/wp-admin/wp-ajax.php', 
           'action' : 'retrieve_content',
           'page_title' : 'clients'
          }, function( response ){
            if ( !response.error ) {
              alert ('AJAX request made! The post title is ' + response.post_title );
            } else {
              alert ('error: ' + response.error );    

in my php functions.php

    function retrieve_content(){
    $page = get_page_by_title( 'clients' );
    $content = apply_filters('the_content', $page->post_content); 

It says Page not found, whereas if I visit the page via URL the content appears. I have hard coded the page title in the PHP function as-well.

share|improve this question

marked as duplicate by toscho Dec 1 '13 at 10:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Have you read $ not defined using jQuery in Wordpress? –  toscho Dec 1 '13 at 9:02
its not the problem with jquery ajax. –  meWantToLearn Dec 1 '13 at 9:04
What is the server's response to the ajax call ? –  Simon Dec 1 '13 at 9:25

1 Answer 1

the problem was the $ not defined, toscho comment was right

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.