WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 was marked as an exact duplicate of an existing 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

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.