Hello i am sending my form with phpmailer ajax and sweetalert, when i got error, sweetalert working but when i got success, sweet alert not working and giving this error for succes… success line not working…But my messages posted and phpmailer working…Just have error succes message…

Uncaught SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data..

("#ambassador").submit(function(e) {  var url = "send4.php"; // the script where you handle the form input..ajax({
       type: "POST",
       url: url,
       data: $("#ambassador").serialize(), // serializes the form's elements.
       success: function(data)
           data = JSON.parse(data);
           if(data.send != 'success'){
               swal("Error!", data.msg, "error");
                swal("Success!", data.msg, "success");

e.preventDefault(); // avoid to execute the actual submit of the form.


Anonymous Asked question May 14, 2021