, , , .
-, $.post(), , , $.ajax(), , , .
, Codeigniter , , , ?
, , , jQuery (, CI), , .
$.ajax(), .
CI:
if( ! $this->form_validation->run($my_form_rules))
{
$this->output->set_status_header(400);
echo validation_errors();
exit();
}
else
{
$result = $this->do_something();
$this->output->set_status_header(200);
$this->output->set_header('Content-type: application/json');
echo json_encode($result);
exit();
}
ajax:
$.ajax({
data: myPostDataObj,
dataType: "json",
type: "POST",
success: function(data) {
alert(data.message);
},
error: function(data) {
alert(data.responseText);
}
});
$.ajax() jQuery , , , , , , , ajax var.responseText.
, - post, , , json-, javascript.
, , , , , , . .