mercredi 6 mai 2015

Send value from controller with ajax Codeigniter

i have javascript like this

$(document).ready(function(){
    $("input[type='checkbox']").change(function(){
        var menu_id = this.value;
        if(this.checked) var statusvalue = "On";
        else var statusvalue = "Off";
        $.ajax({
            type    : "POST",
            url     : "admin/menu/editstatus",
            data    : "id=" + menu_id + "&value=" + statusvalue,
            success : function(data){
                $("#testing").html(data);
            }
        });
    });
});

and my controller named menu and have function editstatus()

public function editstatus()
{
    $data = "asd";
    echo $data;
}

but textbox with id testing not writen anything

Aucun commentaire:

Enregistrer un commentaire