Welcome Guest, Not a member yet? Register   Sign In
Quick JS Question
#1

[eluser]veritascs[/eluser]
I'm newish to javascript and having a little trouble. I got the AJAX part down, I just don't know how to handle the returned array in JS (or maybe I'm passing it incorrectly from CI).

Anyway, here is my JS (using jQuery):
Code:
function getCat(obj) {
    var catID = obj[obj.selectedIndex].value;
    
    $.post("categories/getCat", { category_id: catID },
        function(data){
           formObject = document.forms['modify_category'];
           formObject.elements['category_name'].value = data["category_name"];//THIS IS WHERE IM SUCK
   });
}

My controller:
Code:
function getCat() {
        $category = $this->category_model->getCategoryInfo($this->input->post('category_id'), 'category_id');

        echo $category;
    }

And my model:
Code:
function getCategoryInfo($category, $column_name = 'category_id') {
        $query = $this->db->get_where('categories', array($column_name => $category));

        $row = $query->row();

        return $row;
    }


Messages In This Thread
Quick JS Question - by El Forum - 01-13-2011, 12:57 PM
Quick JS Question - by El Forum - 01-13-2011, 01:14 PM
Quick JS Question - by El Forum - 01-13-2011, 01:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB