[eluser]dauber[/eluser]
It only allows so many characters! But here's the controller as it exists now -- I want it to return the array to the AJAX call (URL helper is in autoload, btw):
Code:
<?php
class Srchgames_ctrl extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('form_validation');
$this->load->database();
$this->load->helper('form');
$this->load->helper('email');
}
function do_search() {
$this->load->model('srchgames_model');
if ($_POST['a2600'] === 'true') {
$search_games['console'][] = '2';
}
if ($_POST['a5200'] === 'true') {
$search_games['console'][] = '5';
}
if ($_POST['a7800'] === 'true') {
$search_games['console'][] = '7';
}
$search_games['manual'] = $_POST['manual'];
$search_games['box'] = $_POST['box'];
$search_games['notes'] = $_POST['notes'];
$search_games['emanual'] = $_POST['manual'];
$search_games['ebox'] = $_POST['box'];
$search_games['enotes'] = $_POST['notes'];
$search_games['include']['smanual'] = $_POST['manual'];
$search_games['include']['sbox'] = $_POST['box'];
$search_games['include']['snotes'] = $_POST['notes'];
$search_games['search_terms'] = $_POST['search_terms'];
$search_games['search_key'] = $_POST['search_key'];
$search_games['rarity_fuzz_drop'] = $_POST['rarity_fuzz_drop'];
$search_games['rarity_options'] = $_POST['rarity_options'];
$search_games['aah'] = $_POST['aah'];
$search_games['aar'] = $_POST['aar'];
$search_games['aap'] = $_POST['aap'];
$search_games['aau'] = $_POST['aau'];
$search_games['include']['gamePlatform'] = $_POST['splatform'];
$search_games['include']['atariagecom_rarity'] = $_POST['rarity'];
$search_games['include']['cartColor'] = $_POST['cart_color'];
$search_games['include']['labelCase'] = $_POST['label_case'];
$search_games['include']['labelStyle'] = $_POST['label_style'];
$search_games['include']['overlay'] = $_POST['overlay'];
$search_result = $this->srchgames_model->search_games($search_games);
return $search_result;
error_log("If you can read this, it didn't return.");
}
}
Here's the AJAX call:
Code:
function validate_list_form() {
var errors = new Array();
var form_data = new Array();
if (($('#a2600').prop('checked') !== true) && ($('#a5200').prop('checked') !== true) && ($('#a7800').prop('checked') !== true)) {
alert("You need to choose at least one console.");
return false;
} else {
$.post('/index.php/srchgames_ctrl/do_search', {
'a2600': $('#a2600').prop('checked'),
'a5200': $('#a5200').prop('checked'),
'a7800': $('#a7800').prop('checked'),
'manual': $('#manual').prop('checked'),
'box': $('#box').prop('checked'),
'notes': $('#notes').prop('checked'),
'emanual': $('#emanual').prop('checked'),
'ebox': $('#ebox').prop('checked'),
'enotes': $('#enotes').prop('checked'),
'search_terms': $('#search_terms').val(),
'search_key' : $('#search_key').val(),
'rarity_fuzz_drop' : $('#rarity_fuzz_drop').val(),
'rarity_options' : $('#rarity_options').val(),
'aah': $('#aah').prop('checked'),
'aar': $('#aar').prop('checked'),
'aap': $('#aap').prop('checked'),
'aau': $('#aau').prop('checked'),
'splatform': $('#splatform').prop('checked'),
'smanual': $('#smanual').prop('checked'),
'sbox': $('#sbox').prop('checked'),
'snotes': $('#snotes').prop('checked'),
'rarity': $('#rarity').prop('checked'),
'cart_color': $('#cart_color').prop('checked'),
'label_style': $('#label_style').prop('checked'),
'label_case': $('#label_case').prop('checked'),
'overlay': $('#overlay').prop('checked')
}, function(result) {
console.log("Here's the result");
console.dir(result);
}).done(function() {
console.log("DONE");
});
}
}