[eluser]LuckyFella73[/eluser]
would be nicer if you would start and post what you allready tried
and where to optimise ..
But I give you a starting point:
Your form could look like:
Code:
<p>
<input type="text" name="item" id="item" value="" /><br />
<input type="submit" name="submit_item" id="submit_item" value="submit item" />
</p>
Place that js in your header (don't forget the js wrapping tags)
and include the jquery.js before this !
Code:
$(document).ready(function()
{
$("#submit_item").click(function ()
{
var item = $('#item').val(); // for each form item you will need an entry here
$.post("form/process", { "item" : item }, // extend the brackets {} with your items seperated with ","
function(data) { // when your callback func. answers here we go
// in this example your callback function returned variable "result"
// in json encoded
alert(data.result);
// return a flag (from callback funct.) when the formdata is saved and everything is fine
// print message here -> depending on the flag ("success" or "try again")
}, 'json');
});
});
Your submit item (submit button) has to have the id "submit_item"
In your controller (called "form" in this example) you need the callback
function. Could look like:
Code:
function process()
{
$item = $this->input->post('item');
$item = 'From The Controller '.$item;
$array = '{ "result" : "'.$item.'" }';
echo $array;
}
For I had no php 5 running and this I couldn't use "json_encode()"
I manually encoded the data ...
That should give you a good starting point - I hope.
The js function is more or less a example from the jquery website.