1

I am trying to send data array in Ajax request and it sends data correctly but success and onComplete events are not being called. Code below doesn't alert "dd"

                    var prodData = {};
                    prodData['product']='316';
                    prodData['qty']='1';                       
                    prodData['isAjax']='1';

                    jQuery.ajax({                           
                        url:'<?php echo $this->getBaseUrl() ?>ajax/index/add',                            
                        type:'post',
                        data:prodData,
                        success:function (response) {  
                            alert('dd');
                        }

                    });  

But code in next section does, difference is only extra parameter data.

                    jQuery.ajax({                           
                        url:'<?php echo $this->getBaseUrl() ?>ajax/index/add',                            
                        type:'post',
                        success:function (response) {  
                            alert('dd');
                        }

                    });

What could be the possible reason?

murtza gondal
  • 997
  • 2
  • 12
  • 26

2 Answers2

0

The reason is data option only takes PlainObject or Strings

https://api.jquery.com/jQuery.ajax/

prady00
  • 721
  • 1
  • 6
  • 17
0

When you pass the parameters, you play with them on the server and the response is an error.