1

I am using echo json_encode($data); to send an array back to jquery ajax. I want to get data from json and retrieve it on input text and I got this error like: The URI you submitted has disallowed characters.

I don't know on how to pass data in model. Btw, I'm using codeigniter.

Once I click the edit button, a modal will appear. Please, help me guys!!

Button

<a onclick="edit_content_by_id('.$row->post_id.')" title="Edit"><span class="ti-pencil"></span>

Model

public function GetContentById($id) {
    $query = $this->db->select('*')->from('cms_posts_tbl cpt')->
    join('cms_contents_tbl cct', 'cct.post_id = cpt.post_id')->
    join('cms_category_tbl ccat', 'ccat.post_category_id = cpt.post_category')->
    where('post_id', $id)->get();   

    foreach($query as $row) {
        $data = $row;
    }

    echo json_encode($data);
}

jQuery Ajax

function edit_content_by_id(id) {
    var data = { content_id : id };
    $.ajax({
        type: 'POST', url: 'http://localhost:81/ci_sample/model/GetContentById('+ id +')',
        data: data, dataType: 'json',
        cache: false,
        success:function(data) {
            $('#modal_content').modal('show');
            $('#modal_content').find($('post_title')).val(data.post_title);
        }
    });
}
2
  • What actual values in headers you are sending in request ? Commented Aug 16, 2018 at 10:26
  • Please help me guys. Commented Aug 18, 2018 at 6:20

2 Answers 2

0
header('Access-Control-Allow-Origin:*');
Sign up to request clarification or add additional context in comments.

Comments

0

Go to config.php and configure this variable.

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-@\=';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.