I have jquery ajax function in my codeigniter view that stores a textfiled value into a field in a Mysql database table. The problem is that it stores the white spaces in the data in the form of %20.
Actually I am not even sure if the problem is with the ajax function or what is going on back there.
Jquery:
var url = "<?php echo base_url();?>index.php/it_inventory/saveNewAssetType/" + asset_name;
$.ajax({
type: "POST",
url: url,
success: function()
{
alert("New asset saved!");
}
});
Controller Function:
function saveNewAssetType($asset_name="") {
return($this->it_inventory_model->saveNewAssetType($asset_name))?TRUE:FALSE;
}
Model Function:
function saveNewAssetType($asset_name){
$asset_data = array ('code'=>'','name'=>$asset_name);
return($this->db->insert('asset_types',$asset_data))?TRUE:FALSE;
}
Use rawurldecode() before you insert into the table,