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 8337439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:18:17+00:00 2026-06-09T04:18:17+00:00

I have created jquery-ajax call for php page that creates content by selecting data

  • 0

I have created jquery-ajax call for php page that creates content by selecting data from database based on the id it receives from the first page

the first page index.php have link person1 when I click on person1 it redirects through jquery to details page here is the code :

 $('.details').click(function() { 
        $("a").removeClass("active");
        $(this).addClass("active"); 
             var id = $(this).attr("id");
              $.ajax({  
                type: "GET",  
                url: "details.php",
                data:{pid:id},
                success: function(html){        
                    $("#persons").html(html).fadeIn(1000);

                }  
            }); 

                 return false;  
        });

The content will be loaded here in index.php file:

<div class="row">
    <div class="twelve columns" id="persons" style="display:none" >

    </div>
</div>

the content of details page :

   <?

    if(isset($_GET['pid'])){
$id=(int)$_GET['pid'];
    $sql="select id, name,title,details,image,cat from persons  where id ='".$id."' order by name asc";
    $rs=mysql_query($sql)or die(mysql_error());
    if(list($id,$name,$title,$details,$image,$cat)=mysql_fetch_array($rs)){
  ?>
    <h3><? echo $name;?></h3>
    <h5><? echo $title;?></h5>
    <p align="justify">
        <img alt="<? echo $name;?>" src="images/persons/<? echo $image?>" title="<? echo $name;?>" style="float:right; margin-left:15px;" />
        <? echo $details;?>
    </p>
    <?
    }
    }
?>

how to check if the page has been requested via ajax call or normal php call? and if it is not ajax call, load the content of details page normally ?

  • 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-09T04:18:19+00:00Added an answer on June 9, 2026 at 4:18 am

    You can check the following variable:

    $_SERVER['HTTP_X_REQUESTED_WITH']
    

    It should be ‘xmlhttprequest’ for AJAX requests.

    However, you could simply add a parameter to the URL:

    url: "details.php?thisisanajaxrequest=1",
    

    And simply check the URL variable.

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

Sidebar

Related Questions

I am using jQuery to call a php page (via ajax) that goes to
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a website that uses ajax jquery and facebox. Demo here : http://temp.nevergone.eu/facebox.php
I have a ajax call to a php script that updates my MySQL DB
I have gallery.php that loads images with src path from a database. I also
I have created one web service that will may called from web using jQuery
i have one question about jquery ajax().. I created a table grid and there
I have created some JQuery that will expand a div 'popup' on hover and
I have created a jQuery animation that can be seen by clicking the Preview
Hello I have a jQuery function that will send to a php file some

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.