I have a form that after so many seconds automatically saves the form to a database (well that is my intention)
The script below grabs the values in an jQuery AJAX request and sends this to a controller – but whenever I try to var_dump the values it doesnt seem to work from the serialised array. I can see the parameters are there when I view FireBug in Firefox but cannot seem to print the array – can anyone explain why?
// view logic
var t = setTimeout("autosave()", 10000);
$.ajax(
{
type: "GET",
url: "/questionnaires/autosave",
data: $("form").serialize(),
cache: false,
success: function(msg) {
return false;
}
});
// controller logic
function autosave()
{
$str = parse_str( $this->input->get_post('form') );
var_dump($str); // intend to do an insert query here to the db
}
You most likely dont have
query_stringenabled in your config.php.As a result you wont be able to use
GETreliably. Your best option is to changetype: "GET",totype: "POST",.Then use
$this->input->post()to access post variables. You can reference this information from the Codeigniter Documentation:http://codeigniter.com/user_guide/libraries/input.html