How to call a zend method using Jquery?

0

I have this Jquery function that enables an input for the user to edit a form, when editing and clicking 'Enter' I want to save the change made in the database, without submitting the form. >

- My JQuery function

$(function () {
    $(".nr_ordem_exibicao").click(function () {
        var id_combo = $(this).closest('tr').find('.id_combo').text() // guardo o id do combo referente a linha clicada na tabela;    

        var nr_ordem_exibicao = $(this).text();        

        $(this).html("<input type='text' style='width: 50px;' value='" + nr_ordem_exibicao + "' />");
        $(this).children().first().focus();

        $(this).children().first().keypress(function (e) {
            if (e.which == 13) {
                var novo_nr_ordem_exibicao = $(this).val();
                $(this).parent().text(novo_nr_ordem_exibicao);
                    $.ajax({    
                        type: "post",
                        url: "controllers/CombosController.php",
                        data: { 
                            'id_combo': id_combo,
                             'nr_ordem_exibicao': novo_nr_ordem_exibicao                           
                        }
                 });                                                  
            }
        });

    $(this).children().first().blur(function(){
        $(this).parent().text(nr_ordem_exibicao);        
    });
    });

});

- My Action on the Controller

public function updateOrdemExibicao(){
        $comboModel = new comboModel();

        $data = array(            
            'nr_ordem_exibicao' => $_POST['nr_ordem_exibicao']            
        );

        $id_combo = $_POST['id_combo'];

        $comboModel ->updateOrdemExibicao($data,'id_combo = ' . $id_combo);

    }

- My Model

public function updateOrdemExibicao($data, $id_combo)
    {        
        return $this ->update($data, 'id_combo =' .$id_combo);

    }
    
asked by anonymous 11.12.2017 / 19:31

1 answer

-1
   $(function () {
       $(".nr_ordem_exibicao").click(function (e) {
            e.preventDefault()
    
11.12.2017 / 20:14