Enviar data por post en ajax
Enviar data por post en ajax

Necesito enviar la opción seleccionada en un selected (html) por post al archivo llamado por el ajax, el cual que me carga el datatable. Pero no me esta funcionando.
Algo así:
manageCategoriesTable = $('#manageCategoriesTable').DataTable({
'ajax' : {
'url' : 'php_action/fetchCategories.php',
'data' : { 'opselect' : opselect },
'type' : 'post'
},
'order': []
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Can you give more details - saying it doesn't work doesn't give us much to help you with.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hola! Así estará bien: https://codepen.io/cesar2705/pen/YzPVzxe
Using
{ 'opselect' : opselect }
is passing the HTMLselect
into the ajax.data parameter causing theUncaught TypeError: Illegal invocation
error. You need to get the selected value or text, depending on which you want to pass in the parameter.Change your code to something like this to get the selected option's text:
Note the addition of the
destroy
option. If you don't have this then you will get the error in the technote on your second select.Kevin
Hola! Muchas gracias kthorngren por la ayuda. Modifique mi función y todo funciona perfecto. Saludos!