Trying to go back to basics here and send a JSON object via ajax to my php. I can't even get to that part as I get a JSON error. Here is the jquery code:
jQuery(".deletebutton").on("click", function() {
var employees = [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName": "Jones" }
];
var dataString = JSON.stringify(employees);
// Lets put our stringified json into a variable for posting
var postArray = {json:dataString};
jQuery.ajax({
type: 'POST',
url: 'index.php?option=com_recordings&task=deletevideos&format=raw',
data: postArray,
dataType: 'json',
success: function(data){
if (data == "blah")
alert(data);
}
});
});
I get this error (when I check errorThrown): SyntaxError: JSON.parse: unexpected character. I checked with jsonlint.com that it is valid JSON. What am I doing wrong?