8

How to call controller/action in zend framework via jquery/ajax?

I tried this

<script>
     $(function() {
         $(".tbl_repeat tbody").tableDnD({
            onDrop: function(table, row) {
            var orders = $.tableDnD.serialize();
            $.post("<?php echo $this->baseUrl();?>/Indexcodelist/indexcodelistsearch/",{order : orders });
    }
    });
 });
 </script>

this code isn't calling the controller's action method, how do i achieve it?

7
  • What error you are getting? Commented Dec 15, 2014 at 7:07
  • getting no value in the controller in the line: $item_order = $request->getParam('order'); print_r($item_order); Commented Dec 15, 2014 at 7:08
  • 2
    Try to console.log(orders); before $.post(...) Commented Dec 15, 2014 at 7:13
  • 1
    Have you get anything in your browser's console?? Commented Dec 15, 2014 at 8:38
  • 1
    Let us continue this discussion in chat. Commented Dec 15, 2014 at 8:56

2 Answers 2

2

Problem occurred that we have to use single or double quotes when giving the name of passing data in $.post(...) or $.ajax(...) otherwise it interpret it as an javascript object not a name.

$.post("<?php echo $this->baseUrl();?>/Indexcodelist/indexcodelistsearch/",{'order':orders});
                                                                            ^-----^
Sign up to request clarification or add additional context in comments.

Comments

0

Here is my way to work :

<script type="text/javascript">

$('a.validate').click(function(){
        //alert($(this).attr('href'));
        $.post('/application/object/validate',{type:'type', id:$(this).attr('href'), pkObject:$('#pkObject').val()},function(data){
        return false;
    });
</script>

Hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.