This repository has been archived by the owner on Sep 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
ajax.php
72 lines (63 loc) · 2.3 KB
/
ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
require_once 'Jb.class.php';
include_once(dirname(__FILE__) . '/../../classes/MySQL.php');
$jb = new Jb();
if (@$_POST['getsubcategory'])
{
$level = $_POST['level'];
$level++;
$cat = $jb->getCategories($_POST['getsubcategory']);
$html = '<span level="' . $level . '" class="levels level_' . $level . '"><select id="select_category_' . $_POST['getsubcategory'] . '">
' . $jb->buildCategoriesHtml($cat) . '
</select>
<script type="text/javascript">
$(document).ready(function(){
$("#select_category_' . $_POST['getsubcategory'] . '").live("change", function(event){
if ($(this).val() != "")
{
$("#category").val($(this).val());
loadProductStateSelect($(this).val());
$.ajax({
url: \'/modules/jballegro/ajax.php\',
data: \'&level=' . $level . '&getsubcategory=\' + $(this).val(),
type: "POST",
success: function(data) {
$(".levels").each(function(index) {
if($(this).attr("level")>' . $level . ') $(this).remove();
});
$(\'#categories_select\').append(data);
}
});
}
});
});
</script></span>';
echo $html;
}
else if (@$_POST['getstateselect'])
{
$data = $jb->getStateSelectForCategory($_POST['getstateselect']);
if ($data)
{
$html = '<select name="fid_' . $data['sell-form-id'] . '">';
$options = explode('|', $data['sell-form-desc']);
$values = explode('|', $data['sell-form-opts-values']);
$def = in_array(1, $values) ? 1 : $values[0];
foreach ($options as $k => $o)
{
$html .= '<option value="' . $values[$k] . '" ' . ($def == $values[$k] ? 'selected="selected"' : '') . '>' . $o . '</option>';
}
$html .= '</select>';
echo $html;
}
}
else if (isset($_POST['getproduct']))
{
$product = $jb->getProduct($_POST['getproduct']);
echo json_encode($product);
}
else if (isset($_POST['closeauction']))
{
echo json_encode($jb->closeAuction($_POST['closeauction']));
}
?>