jquery - Uncaught TypeError: Illegal invocation in send AJAX -


i checked inputs in variable called reasons , want send withdrawalid , reasons in ajax request. code:

$('body').on('click','#submitreason', function () {     var wdid = $('.modal').attr('id');     var reasons = $('input:checked').map(function () {         return $(this).val();     });      $.ajax({         type: "post",         url: ajax_url,         datatype: 'json',         data: {             withdrawalid: wdid,             reasons : reasons         },         success: function(data) {             if (data == 'success') {             } else  {             }         }     }); }); 

when try send ajax request error; think problem because of reasons variable;

var reasons = $('input:checked').map(function () {     return $(this).val(); }); 

when add dataproccess = false; data sent [object object] , response empty whenever use var_dump($_post).

any ideas issue is?

you need use get() retrieve array of integer values map():

var reasons = $('input:checked').map(function () {     return $(this).val(); }).get(); 

see this fiddle example of difference between two.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -