[eluser]nanetorg[/eluser]
Hi all!
I just finish read this articles
http://www.weblee.co.uk/2009/06/10/simpl...er-part-4/
and I still can pass variables from form to my controller using ajax :/
here is my controller:
Code:
public function check() {
// secure
if (!$this->input->is_ajax_request()) redirect(base_url());
// vars
$callback = ''; // here i want a value of input in my form on view page
// valid
// output
echo $callback;
}
here view:
Code:
<form action="<?php echo base_url(); ?>upload" method="post" enctype="multipart/form-data" id="upload-form">
<div class="show_upload" id="upload-local">
<input type="file" name="file_local" value="" />
</div>
<div class="hide_upload" id="upload-remote">
<input type="text" name="file_remote" value="" />
</div>
<a id="upload-button"><span>Upload</span></a>
</form>
and here my ajax code:
Code:
var upload_url = '<?php echo base_url(); ?>upload/check';
var upload_form = "#upload-form";
$.ajax({
url: upload_url,
type: 'post',
data: $(upload_form),
dataType: 'html',
success: function(callback) {
if (callback !== '') {
html = '<div><a class="box error corners"><span class="close"> </span>' + callback + '</a></div>';
$(info_box).append(html);
$(info_box).slideDown(slide_delay);
}
else {
$(upload_form).submit();
return false;
}
}
});