I think this might be useful in future for many others. First of all, I know that there's com_ajax for this kind of a job, but I do not want to use it. Is there an alternative?
What I got:
default.php
<form method="post" name="filterForm">
<input type="checkbox" name="checkboxList[]" value="1">value1</input>
<input type="checkbox" name="checkboxList[]" value="2">value2</input>
<input type="checkbox" name="checkboxList[]" value="3">value3</input>
</form>
jQuery(function($) { // DOM is now ready
$("input[type=checkbox]").on("change", function() {
var data = $("filterForm").serialize();
$.ajax({
url: "/modules/mod_mymodule/mymodule.php",
type: "POST",
async: true,
cache: false,
data: ({data: data}),
dataType: "text",
});
});
});
mymodule.php
//defined('_JEXEC') or die; <-- So it's possible to access this file
print_r($_POST);
I get an empty array. What is wrong?