Jump to content

Unexpected end of Json input


Moorcam

Recommended Posts

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 by DanEthical
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.