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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:47:23+00:00 2026-06-14T06:47:23+00:00

My script.js performs a request to get_all.php which has three variables to output (echo)

  • 0

My script.js performs a request to get_all.php which has three variables to output (echo) $all_categories, $all_brands and $all_filters. Now I want to manipulate these in three different areas in my index.html.

I want to place $all_categories in <div id="caregories">, $all_brands in <div id="vrands"> and $all_filtesr in <div id="filters">.

How can I place them separately in each div ? I know how to place all of them in one <div> but have no idea how to place each variable, received, separately.

index.php

<?php // Startup ?>

<?php 

    define('APP_PATH', '../');
    define('SYS_PATH', '../system/');
    define('STYLES', 'assets/styles/');
    define('SCRIPTS', 'assets/scripts/');

    require_once SYS_PATH . 'initializers/all.php'; 

?>

<?php // Controller ?>

<?php



?>

<?php // Viewer ?>

<?php template('header'); ?>

<body>

<div id="static_menu">
    <ul>
        <li><a href="#categories">Categories</a></li>
        <li><a href="#brands">Brands</a></li>
        <li><a href="#filters">Filters</a></li>
        <li><a href="#social">Social</a></li>
    </ul>
</div>
<hr>
<div id="categories">
    <ul></ul>
</div>
<hr>
<div id="brands">
    <ul></ul>
</div>
<hr>
<div id="filters">
    <ul></ul>
</div>
<hr>
<div id="social">
    <ul></ul>
</div>
<hr>

</body>

<?php template('footer'); ?>

script.js

// DOM ready
$(function(){

    // get categories, brands, filters and social
    $.ajax({
        type: "POST",
        url: "get_all.php"
    }).done(function(data){
        // manipulate recieved in three different divs
    })

});

get_all.php

<?php // Startup ?>

<?php 

    define('APP_PATH', '../');
    define('SYS_PATH', '../system/');
    define('STYLES', 'assets/styles/');
    define('SCRIPTS', 'assets/scripts/');

    require_once SYS_PATH . 'initializers/all.php'; 

?>

<?php // Controller ?>

<?php

$result_arr = $category->select_all();
$all_categories = $html->list_anchor_loop($result_arr, 'category');
echo $all_categories

$result_arr = $brand->select_all();
$all_brands = $html->list_anchor_loop($result_arr, 'brand');
echo $all_brands;

$result_arr = $filter->select_all();
$all_filters = $html->list_anchor_loop($result_arr, 'filter');
echo $all_filters;
  • 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-14T06:47:24+00:00Added an answer on June 14, 2026 at 6:47 am

    Have your PHP script send the result as a JSON object (see json_encode).

    In your JS, you’ll receive an object, say resp, which will have three properties, resp.categories, resp.filters and resp.brands

    For more details and specificity, post some code.

    In get_all.php :

    $result = array(
      'categories' => $all_categories,
      'brands' => $all_brands,
      'filters' => $all_filters
    );
    
    echo json_encode($result);
    

    In script.js

    $.ajax({
        type: "POST",
        url: "get_all.php",
        dataType : 'json', //specify that data will be returned as JSON
    }).done(function(data){
        // use data.categories, data.brands, data.filters here
        // manipulate recieved in three different divs
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I perform an AJAX request to a PHP script in JavaScript and by using
I wrote a user script that performs a certain operation on selected text in
I need a python script to perform a GET request on 2 urls. I
I have a form element which is being pulled in on request with ajax.
The Objective : A script which cycles through a list of proxies and sends
I've got an updater.php script located on several of my sites. This updater.php file
One thing I have noticed with php, is that nothing is output to the
I have a controller (address /Home/Test see below) which definately responds to get request
I'm trying to run the simplest python script to perform a http request and
Im writing a bash-script to perform an offsite backup, using rsync over SSH. I'm

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.