Reputation: 66
Hello I'm new in angular js and codeigniter.
So I got problem with sending object from angularjs services, to codeigniter controller.
there are my code.
angular (service.js) :
help.updateProductService = function(products){
return help.http({
url: "/www/Rubee/index.php/pages/editProduct/",
method: "POST",
data: $.param({
"product" : products
}),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
})
}
codeigniter (pages.php) :
public function editProduct(){
print_r($_POST);
print_r($this->input->post('product'));
}
and I got an error "Disallowed key character. $$hashKey" so am I wrong with the code? or any better way to solve this?
SOLVED ======================================
So if you have same problem like me, go to your folder system/core/input.php
and find function _clean_input_keys($str), the function block should be like this :
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.');
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
return $str;
}
so you can see preg_match, that contain regular expression. you can add your exception to that regular expression. or if you don't know what to do just block that code and return $str only.
Upvotes: 2
Views: 1154
Reputation: 66
I know this is old but to get rid of the $$hashKey in your post, use angular.copy() to remove it. So:
data: $.param({
"product" : angular.copy(products)
})
Upvotes: 3