SyntaxError: invalid label

Hello It took hours now and I don't have a clue whats going on here. I always get the following error, when i send the ajax request with jquery 1.8:

"SyntaxError: invalid label"

This is my code...

        $(document).ready(function() {

    $("#create-workspace-button").click(function () {
        show_dialog($(this));
    })
    $("#submit-create-workspace").live("click", function(event){
        event.preventDefault();
        category= $("#id_workspace_category").val();
        workspace_name=$("#id_workspace_name").val()
        var json_data = JSON.stringify({
            "cat":category,
            "workspace_name":workspace_name

        })
        $.ajaxSetup({
            headers: {
                'X-CSRFToken': $("input[name=csrfmiddlewaretoken]").val()

            }
        })
        $.ajax({
            type:'POST',
            data:json_data,
            url: '/workspace/create/',
            success: function(data) {
                alert('hi')



            },
            error: function(jqXHR, textStatus, errorThrown)
            {
                //here a label error happens...i dont know why
                console.log(errorThrown)
            }
        })


    });




    $("#close").click(function () {
        close_dialog($(this));
    })



    function close_dialog(thiz){
        $(thiz).fadeOut(function(){
            $('#layer,.form-submit-dialogbox').fadeOut();
        })
    }
    function show_dialog(thiz){

        $('#layer,.form-submit-dialogbox, #close').fadeIn();
    }
})

edit "JSON.stringify(" was missed out...but same error

Answers


Are you asking about a syntax error or a reference error? You've edited the code but not the title...

Your reference error could be because you're referring to the global console object, which in some browsers only exists when the console is open.

Your syntax error could be because of the extra closing parenthesis ) at the very end of your code, but without seeing the wider context it's hard to tell.


Need Your Help

background switch page load

jquery background switch-statement

I've seen a lot of different background switching based upon link classes, however I just want a simple background switcher on any page load (no cookies) and not link dependent.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.