Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6369837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:51:17+00:00 2026-05-25T00:51:17+00:00

I have an editcategory view which shows details about a category and also a

  • 0

I have an editcategory view which shows details about a category and also a table of category descriptions showing at the bottom of the view.

The category description table has two anchor tags for edit and delete. I am using ajax to pass the id of the description to be edited. A function in the controller needs to be called, which calls the categorydescription model and pulls the record based on the id passed.
The controller needs to feed the catDescription array back to the ajax success function.

There is already a hidden div that contains the form for editing the description but the values are set as follows

 <label for="catlang_name">Name</label>
 <input type="text" name="catlang_name" id="catlang_name" class="text ui-widget-content ui-corner-all"  value="<?php echo set_value('catlang_name',$catDescription->catlang_name); ?>"/>

My problem is how I can get the response back in Ajax and assign the

For normally passing the data to the view i could have done the following from within the controller

$data['catDescription']=$this->CategoryModel->getCategoryDescriptionById($id)
$this->load->view('category/categoryEdit', $data,true);

This is the data returned from the model :

Array (
    [0] => Array (
        [catlang_id] => 1
        [catlang_cat_id] => 10
        [catlang_lang_id] => 2
        [catlang_name] => french
        [catlang_description] => test
    )
    [1] => Array (
        [catlang_id] => 2
        [catlang_cat_id] => 10 
        [catlang_lang_id] => 2
        [catlang_name] => english
        [catlang_description] => test
    )
)

Any suggestions would be much appreciated.

cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:51:18+00:00Added an answer on May 25, 2026 at 12:51 am

    To pass the array back to the ajax function, you should return it as JSON.

    In your controller, rather than calling a view, write this:

    $this->output->set_output(json_encode($array));
    

    Which will output the array in JSON, that the ajax function can process. I suppose you’re using jQuery for handling the ajax, and if you aren’t yet using jQuery, do so.

    $.ajax(
        url: '<?php echo site_url() ?>category/categoryEdit.php'
        dataType:'json',
        success: function(data) {
            $.each(data, function(index,value){
                //process your data by index, in example
                $("#catlang_name").val(value.catlang_name);
            });
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have deployed numerous report parts which reference the same view however one of them
Quick question about CI. I have a view with a form, several text input
I have created one plugin which i want to display at the bottom of
I have to select category name,description,id from the tbl_ticket_categories from that selected id I
I have written a very simple function: function editCategory() { $ID = urlencode($_GET['id']); $cname
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have 2 questions : A computer with 32-bit address uses 2-level page table (9
I have a java script code which will set some values in a form
I have assigned a click event to a button, which retrieves a different HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.