[eluser]Sven Delle[/eluser]
I'm trying to pass form data to CI through jQuery AJAX. But whenever I try to actually SET the dataType to json I get NO response from the server.
Code:
$(function(){
$('#form_id').submit(function(event) {
event.preventDefault();
var form_data = $('#form_id').serialize();
$.ajax({
url: 'http://localhost:8080/website/admin/update_record/',
type: "POST",
data: { form_data : form_data },
// data: form_data, // ALSO TRIED THIS
dataType: 'json', // TOGGLED THIS IN ALL CASES
success: function(msg)
{
alert('Success: ' + msg);
}
});
// prevents from refreshing the page
return false;
});
});
For testing purposes I simply want to alert what's received on the server.
Code:
var_dump($this->input->post());
Also tried:
Code:
var_dump($this->input->post('form_data'));
I can get post data as array, but whenever I uncomment the dataType : 'json' I get absolute SILENCE from the server.
Now, is that because nothing gets sent to the server?
Or, am I trying to access it the wrong way ($this->input->post() and it ISN'T post data, or?)
Can someone shed some light in this for me. I'm trying to use json as it seems easier (yeah, right - not so far) with updating database.