0

I am fairly new to codeigniter, and can't seem to get this right. I have a bootstrap model which should display values from a database. Now the problem is that my requirement is to fetch the values from a database using AJAX, and insert it to the relevant fields[form inside Modal]. I know how to insert data into using AJAX, but have never used it to retrieve and populate something.

Please can someone solve this dilemma, I'm having this problem for hours now...

1 Answer 1

1

Onclick of a button, simply make a Ajax call to controller.

  $('#button').click( function(){
     $.ajax({
                type: "POST",
                url: "your url to controller function here",
            }).done(function( html ) {
                $(".bootstrap_modal").html(html);
            });

In the controller function call a Model Function to run a query and get the result set.

Now

   $data['result'] = $this->model_name->function_name();
   $this->load->view('views/reveals/modal_content', $data);
Sign up to request clarification or add additional context in comments.

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.