Requirements for this task is - I can NOT use any type of components (com_ajax is out of the options list)
GOAL: send post data if checkboxes are 'checked' using ajax within custom module.
Is my AJAX code correct? To be specific, if URL is right? I know that 'defined('_JEXEC') or die;' won't allow to send post data to specific file like this, but even if I comment it out, I don't succeed to get POST data. What could be wrong? I try to access POSTED data in mod_test.php with print_r($_POST);
Is there alternative way to send posted data (not using components) to my module helper.php/mod_test.php file? I'm open to creative brain-storming.
function function1() { var data = $("[name='form1']").serialize(); $.ajax({ url: "modules/mod_test/mod_test.php", type: "POST", async: true, cache: false, data: data, success: function(data){ alert(data); } }); }
<form method="post" action="this.form.submit();" name="form1"> <input type="checkbox" name="checkboxList[]" onclick="function1();" value="1">value1</input> <input type="checkbox" name="checkboxList[]" onclick="function1();" value="2">value2</input> <input type="checkbox" name="checkboxList[]" onclick="function1();" value="3">value3</input> </form>
Any real code example would be flawless.