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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:20:06+00:00 2026-06-06T08:20:06+00:00

I am calling a contacts list from a MySQL database using AJAX in PHP

  • 0

I am calling a contacts list from a MySQL database using AJAX in PHP page. The data is called correctly, but when I call the PHP page in the browser, I can see the contacts list (data from DB) is being displayed in the top of the page before the meta data. The list should be displayed in the defined DIV, but for some reason it is not. Below is my code:

Ajax Code:

function getUserList(){

var ajaxDisplay = myform.getElementById('displayList'); // HTML Div where data should be displayed 

 try{ //for Firefox, Chrome, Opera, Safari, IE7+

  var activeX = new XMLHttpRequest(); //initializing object
 }catch(e){

   try{// for IE5 , IE6
    var activeX = new ActiveXObject(Msxml2.XMLHTTP);
   }
   catch(e){

    alert("Dude your browser is in Jurassic era!");
   }
 }

  activeX.readystatechange = function{

   if(activeX.readyState == 4){
    var queryResult = activeX.responseText;

   if(!queryResult){
    ajaxDisplay.innerHTML = 'Error in populating list';
   }else{
    ajaxDisplay.innerHTML = queryResult;
   }

   }
 }

    activeX.open("GET", "?action=contactsandgroups", true);
    activeX.send(null);
}

PHP/HTML code:

<div class="contacts_list_data_contacts" id="displayList"></div>

MySQL Function:

while($row=mysql_fetch_assoc($res_info)){

print '<div class="contacts_headings_01">
<div class="contacts_checkbox_01"><input name="contact_id[]" id="contact_id" type="checkbox"  value="'.$row['contact_id'].'" style="margin-top:0px ; margin-left:-3px;" /></div>
<div class="contacts_firstname_01_contacts">'.$row['firstname'].'</div>
<div class="contacts_firstname_01">'.$row['lastname'].'</div>
<div class="contacts_firstname_01">'.$row['company'].'</div>
</div>';
} 

When I view the page source, it shows that it prints the data at the top of the page. This happens in Firefox, Chrome, and Internet Explorer.

  • 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-06T08:20:08+00:00Added an answer on June 6, 2026 at 8:20 am

    What I see is, you want this output of ?action=contactsandgroups to be populated inside div#displayList. If that is the case, please try the following:

    Add this in your <head> part:

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript">
        function getUserList()
        {
            ajaxDisplay = $("#displayList");
            ajaxDisplay.load('?action=contactsandgroups');
        }
    </script>
    

    Try it out and see if it works. If not, send me the HTML Code, where you call the function.

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

Sidebar

Related Questions

Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need
In my app, I get the name of the person calling from the contacts
I am using a custom List adapter to display a list of all contacts,
From the Android documentation, I gather that I can append the ContactsContract.Contacts.Data.CONTENT_DIRECTORY string to
Im having problem in importing hotmail contacts from hotmail in php it simple give
I have a page which list, a list of volunteers from the volunteer_list table.
Calling Html.RenderPartial(~/Views/Payments/MyControl.ascx); from a view works if MyControl.ascx is a control that directly inherits
Calling urrlib2.urlopen on a link to an article fetched from an RSS feed leads
When calling functions that always throw from a function returning a value, the compiler

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.