Moorcam Posted September 4, 2021 Share Posted September 4, 2021 (edited) Hi folks, Getting the following error in Console when submitting data to MySQL via Bootstrap Modal: VM6553:1 Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at Object.success (tickets.php:391) at j (datatables.min.js:14) at Object.fireWith [as resolveWith] (datatables.min.js:14) at x (datatables.min.js:17) at XMLHttpRequest.b (datatables.min.js:17) Here is my JS <script> $(document).ready(function() { // add $(document).on("click", "#submit", function() { var title = $('#title').val(); var body = $('#body').val(); $.ajax({ url: "includes/add-ticket.php", type: "POST", catch: false, data: { added: 1, title: title, body: body }, success: function(dataResult) { var dataResult = JSON.parse(dataResult); if (dataResult.status == 1) { $('#add_ticket').modal().hide(); swal("Ticket Submitted", { icon: "success", }).then((result) => { location.reload(); }); } } }); }); }); </script> Data is being submitted but the modal doesn't close after submit and the above error shows in Console. Can anyone help with this? Google doesn't want to help. Cheers Edited September 4, 2021 by DanEthical Quote Link to comment https://forums.phpfreaks.com/topic/313661-unexpected-end-of-json-input/ Share on other sites More sharing options...
kicken Posted September 4, 2021 Share Posted September 4, 2021 Log your dataResult variable before you try and parse it. console.log(dataResult); Sounds like it's incomplete, you need to figure out why. Quote Link to comment https://forums.phpfreaks.com/topic/313661-unexpected-end-of-json-input/#findComment-1589646 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.