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

  • SEARCH
  • Home
  • 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 8783211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:46:18+00:00 2026-06-13T20:46:18+00:00

When my ajax is processed $.post(main.php, {data: $(this).text()}, function(data) { //alert(Data saved.); $(‘#demo’).html(data); });

  • 0

When my ajax is processed

$.post("main.php", 
          {data: $(this).text()}, 
          function(data) {
               //alert("Data saved.");
               $('#demo').html(data);
          });   

instead of getting what I specified in the below query

if (isset($_POST['data'])){
$data = $_POST['data'];

    $query = mysql_query("SELECT * FROM tempusers
    WHERE 'firstname' LIKE '%$data%' 
        OR 'lastname' LIKE '%$data%' 
        OR 'title' LIKE '%$data%'");

    while($row=mysql_fetch_assoc($query)){
                $firstname=$row['firstname'];
                $lastname=$row['lastname'];
                $grade=$row['grade'];


    echo $grade;

Instead I get all the elements in my page returned. So in other words in the div below

 <div id="demo"></div>

I’m returning my page. So it shows as a website within a website. It won’t even show echo $grade; I thought it was my query acting up, but I tried commenting out the query and just echo $data see below

if (isset($_POST['data'])){
$data = $_POST['data'];
echo $data; 

And doing so gave me the same result as stated previously “echoing out the website within the website” and also echoed the $data I wanted. I would be overjoyed to understand how this happened as well as what I can do to fix this problem and get my isset function/ajax corrected. Any other tips would be greatly appreciated. I know I need to change the query to PDO and plan on it.

  • 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-13T20:46:19+00:00Added an answer on June 13, 2026 at 8:46 pm

    After you echo what you want, put an explicit exit to terminate any further script execution.

     echo $grade;
     exit;
    

    If the grade echo is in a loop, put the exit after the loop termination.

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

Sidebar

Related Questions

this ajax function gets a textbox value and sends it to response.php : (this
This is a general question about using Ajax on data that is not text/string.
AJAX Call $.ajax({ url: '/api/Inventory', cache: false, type: 'POST', data: json, contentType: 'application/json, charset=utf-8',
AJAX code: <script type=text/javascript> function doCalc(){ var roomX = $('#room_str').val(); var heightX = $('#height_str').val();
.ajax({ type: 'POST', url: '..serverices/ajaxserver.asmx', data: 'lname='+ $('#lastname').val() }); return false; if #lastname has
ajax tutorial on w3school at http://www.w3schools.com/ajax/ajax_database.asp In this function (function GetXmlHttpObject()), it creates a
I am using an AJAX script to post data from a form and return
I have this function $.ajax({ url: aurl, method: 'GET', beforeSend: function (req) { req.setRequestHeader('Authorization',
My HTML which is at this url '/main/' contains the following link: <a href=/main/
I have a javascript function that enters a loop and issues an asynchronous ajax

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.