How to call a zend method using Jquery?

Asked

Viewed 89 times

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 in 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);

    }

1 answer

-1


   $(function () {
       $(".nr_ordem_exibicao").click(function (e) {
            e.preventDefault()
  • This will not work, when clicking on 'Enter' I want to call a function of the Zend Framework passing the parameters I received from the user.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.