I've never run into this situation I'm having now. And am using this setup in another part of the site. I cannot figure out why I don't get any post data, my session variables never update.
Here is the html form, dynamically creating a row of check boxes:
$html .= '<form id="status_form">';
foreach ($leads as $key => $type) {
$html .= '<input type="checkbox" name"' . $key . '" id="' . $key . '" class="box_status" value="1"';
if (something = true) {
$html .= ' checked="checked"';
}
$html .= ' />';
$html .= '<label class="checkbox-inline" for"' . $key . '">' . $type . ' (' . @$count[$key] . ')</label>';
}
$html .= '</form>';
echo $html;
Each time a checkbox is checked, javascript is submitting the form to primarily update session variables and then reload the page:
function update_report() {
var form_data = $("#status_form").serialize();
$.ajax({
type: 'POST',
url: 'scripts/test.php',
data: form_data,
success: function() {
window.location.reload(true);
}
});
}
$('.box_status').change(function(){
update_report();
});
And here is the test.php file:
session_start();
if (isset ($_POST)) {
$_SESSION['crm']['reports']['index'] = array();
foreach ($_POST as $k => $v) {
$_SESSION['crm']['reports']['index'][] = $k;
}
$_SESSION['post'] = $_POST;
echo true;
}
I've double checked and the form is displayed correctly, the ajax makes the call, I've done "hello world" checks in test.php.. it even goes into the if(isset($_POST))
portion, but the session variables don't change, and if I assign $_POST
to another session variable, it shows me nothing.