SyntaxError: JSON.parse: unexpected character at line 1 column 1 of JSON data

I have searched all the solutions, but I can't find anything that works, I keep getting the following error: I have a submit event that will call the SUValidation function with data that is submitted via a textbox in a php form, I tried to put contentType: " application / json ", // notice the contentType definition looking at other messages, but nothing helped. Can anyone provide guidance on how to debug this error or provide a solution at best

Mistake: -

SyntaxError:JSON.parse:unexpected character at line 1 column 1 of the JSON data

      

ANSWER FOR SUVALID.py

Just outputs the content of the python script

      

Hello,

send event: -

$("#su_validation").submit(function(event) {
    console.log("su_validation.submit");
    event.preventDefault();
    //SUValidation('#su_validation', '#su_validation_table', '#gerrits_su_validation', showDialog, "#su_validation_dialog");
    $("#SUValidation_su_validation_table").empty();

    var data = { 'product_lines' : [], 'gerrits' : [], 'contacts' : []};
    //find all pl that are checked
    data['product_lines'] = ($("#product_line_su_validation").val()).split(",");

    data['gerrits'] = ($("#gerrits_su_validation").val()).split(",");
    data['contacts'] = ($("#contacts_su_validation").val()).split(",");
    console.log(data);

    SUValidation(data, '#SUValidation_su_validation_table', '#gerrits_su_validation', "su_validation_form");


});

      

Function call: -

function SUValidation(data, table_name, gerrit_form, caller) {
    console.log("su_validation_form");
    console.log(data);

    //console.log($(form_name).find('input, select, textarea').serialize());
    su_validation_return = null;

    //if maintained, we care if they are in ODS
    //if not maintained, we don't really mind if they aren't in ODS database
    var maintained = null;
    console.log("start when");
    $.when(     
        $.ajax({
            dataType: "json",
            type: "POST",
            url: "scripts/suvalid.py",
            timeout: 180000,
            data: JSON.stringify(data),
            success : function(response){
                su_validation_return = [];
                console.log("python");
                console.log(response);
                ....
                    }
                }                
            },
            error: function (xhr, ajaxOptions, thrownError) {
                console.log("error");
                //alert(xhr.status);
                alert(thrownError);
            }
        })      
    ).then(function() {
        console.log("THEN");
        var gerrits = data['gerrits'];
        console.log(su_validation_return);
        var valid_gerrits = true;
        ..................

      

+3


source to share





All Articles