Vicki
Vicki

Reputation: 1456

Syntax Error Jquery AJAX calling

I am getting this syntax error because I am missing an } can someone please tell me what I may be overlooking... this says line 25 but I do not see it.

Error

SyntaxError: missing } after property list

Code

$(document).ready(function(){
    // What happens when a user hits the "Accept" button on the dealer form
    $(".label_accept").click(function(){
        $('#LabelMaker').modal('hide');

    });

    $('#labelForm').on('submit', function(e){
        e.preventDefault();
        alert($(this).serialize());
        $.ajax({
        // the location of the CFC to run
        url: "index_proxy.cfm",
        // send a GET HTTP operation
        type: "get",
        // tell jQuery we're getting JSON back
        dataType: "json",
        // send the data to the CFC
        data: $('#labelForm').serialize(),
        // this gets the data returned on success
        success: function (data){
            console.log(data);
        }
        // this runs if an error
        error: function (xhr, textStatus, errorThrown){
        // show error
        console.log(errorThrown);
        }
   });
});

Upvotes: 0

Views: 198

Answers (2)

user3320657
user3320657

Reputation:

You missed a comma and then a closing block. Check the lines where I've commented as missing.

$(document).ready(function () {
    // What happens when a user hits the "Accept" button on the dealer form
    $(".label_accept").click(function () {
        $('#LabelMaker').modal('hide');

    });

    $('#labelForm').on('submit', function (e) {
        e.preventDefault();
        alert($(this).serialize());
        $.ajax({
            // the location of the CFC to run
            url: "index_proxy.cfm",
            // send a GET HTTP operation
            type: "get",
            // tell jQuery we're getting JSON back
            dataType: "json",
            // send the data to the CFC
            data: $('#labelForm').serialize(),
            // this gets the data returned on success
            success: function (data) {
                console.log(data);
            }, // missing comma
            // this runs if an error
            error: function (xhr, textStatus, errorThrown) {
                // show error
                console.log(errorThrown);
            }
        });
    });
}); // missing close block

Upvotes: 4

Rory McCrossan
Rory McCrossan

Reputation: 337743

You're missing a comma (,) after the success handler function:

success: function (data){
    console.log(data);
}, // < here
error: function (xhr, textStatus, errorThrown) {
    console.log(errorThrown);
}

Upvotes: 2

Related Questions