Here is my jQuery code. I'm having problems correctly formatting the data in JSON, and the request is failing. What do I need to do to send it correctly, and be able to decode it on the server?
$(".comment_button").click(function() {
var chkarray = [];
$('.webInput:checked').each(function(){
chkarray.push($(this).val());
});
var dataString = "content="+ chkarray;
if(test=='')
{
alert("Please check checked");
}
$.ajax({
type: "POST",
url: "chkoutput.php",
dataType:'json',
data: dataString,
cache: false,
success:
function(html)
{
$("#test_area").after(html);
document.getElementById('content').value='';
$("#flash").hide();
}
});
This is the server-side code:
$chk_out = $_POST["content"];
echo json_encode($chk_array);