Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
    
ehmm... still not working. If I try data, and debug my javascript with chrome. in network tab i can see my data send by the angular. but I don't understand why it's always null when I try access it from codeigniter. –  uyea Jan 21 at 14:46
    
Are there any key post data that has a dot in it? –  Nouphal.M Jan 21 at 14:51
    
no it's just like this {"product":[{"id":"1","product_name":"apple","price":"11","discount_price":"1"}]‌​} –  uyea Jan 21 at 14:56
    
stackoverflow.com/questions/11442632/…. Also check this file system/libraries/Input.php in codeignitor –  Nouphal.M Jan 21 at 15:20
    
Hello, It's still not working, but I'll do some research again. Thank you for the reference anyway. –  uyea Jan 22 at 2:34
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.