--Im want to fetch data based on POST values ($data) by ajax.Code:if(isset($_POST['checkboxList'])){$data = $_POST['checkboxList']; // Possible results: 1; 12; 123 (checkbox value)}if(isset($_POST['thisisajax'])){$ajax_test = $_POST['thisisajax'];}if($ajax_test){$db = JFactory::getDbo();$query = $db->getQuery(true);$query->select('*');$query->from($db->quoteName('#__products'));$query->where($db->quoteName('id') . ' = (', implode(",",$data));// var_dump($query->__toString()); Doesnt work... Why?$db->setQuery($query);$results = $db->loadObjectList();$response = $results;echo new JResponseJson($response);jexit();}<form method="post" action="" name="form1" id="mycustomform"><input type="checkbox" name="checkboxList[]" onclick="function1();" value="1"> Apple</input><br><input type="checkbox" name="checkboxList[]" onclick="function1();" value="2"> Pineapple</input><br><input type="checkbox" name="checkboxList[]" onclick="function1();" value="3"> Pen</input></form><div id="response"></div><script>function function1() {var data = jQuery("#mycustomform").serialize() + '&thisisajax=1';jQuery.ajax({url: "<?php echo JUri::current(); ?>",type: "POST",data: data,success: function(response){response = jQuery.parseJSON(response);if(response.success === true){jQuery('#response').html(response.data);} else {alert('error');}}});}</script>I've two questions:1) How can I debug my code? I cant do var_dumps for queries ect. Is it because ajax? How can I work around this?2) Why I get this error? "Uncaught SyntaxError: Unexpected token < in JSON at position 0"Is something wrong with the query? How to fix these kind of bugs, when u cant do var_dumps?
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send email to joomla-dev-general@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.