私のscript.jsは、出力する3 つの変数 (echo)$all_categories
と. ここで、これらをindex.htmlの 3 つの異なる領域で操作したいと考えています。$all_brands
$all_filters
、、 、に配置$all_categories
したい。<div id="caregories">
$all_brands
<div id="vrands">
$all_filtesr
<div id="filters">
それぞれに別々に配置するにはどうすればよいdiv
ですか? それらすべてを 1 つに配置する方法は知って<div>
いますが、受け取った各変数を個別に配置する方法がわかりません。
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;