Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:49:39+00:00 2026-06-16T01:49:39+00:00

In this script, using php’s return will not work, whereas echo will. Thing is,

  • 0

In this script, using php’s return will not work, whereas echo will. Thing is, if I use echo, and someone where to access the page directly, they would be able to see the output without the formatting.

<script type="text/javascript">
$(function() {

    $('.callAppend').click(function() {
             $.ajax({
                type: 'GET',
                url:  'recent.php',
                dataType:'HTML',
                cache:false,

                success: function(data){
                console.log(data);

                //}       

              },

            });    

        return false;
    });
});
</script>

This the php script

<?php
$feedback = 'Hello this is the php page';

return $feedback; //Use echo, and all works fine.
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:49:40+00:00Added an answer on June 16, 2026 at 1:49 am

    return is used for returning a value from a function to another piece of PHP code.

    jQuery is not part of the execution of the PHP code on the server, so it has no idea what is really going on server side. jQuery is waiting for the rendered server response, which is what echo provides.


    This SO answer provides a solution to only allow an AJAX script to be called by that type of request:
    Prevent Direct Access To File Called By ajax Function

    Even though it is checking for ‘XMLHttpRequest’, someone could make this type of request from something else other than you weboage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am indexing a pdf file using this php script. The curl give me
I want to display an image using this php script on my server. $file
After loading a PHP template (using jQuery's load function), this simple script won't make
im using a simple test script from http://www.tuxradar.com/practicalphp/8/11/0 like this <?php $fp = fopen(foo.txt,
I am not familiar with php and want to write a redirect script using
This script will get a website address dynamically from the url. Example: www.site.com/fetch.php?url=http://www.google.com to
I'm trying to back a database via a PHP script using this one simple
I need to develop a script using Wordpress PHP that will run with the
I'm trying to run an R script from php using the following: echo <form
edit3: i am using this script inside a facebook app, and not sure how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.