SyntaxError:JSON.parse:JSON数据的第1行第1列的意外字符

时间:2015-04-23 23:49:39

标签: javascript ajax json

我一直在寻找解决方案,但我找不到任何有用的东西,我一直收到以下错误,我有一个提交事件,它会调用函数SUValidation,数据是 通过php格式的文本框提交,我已经尝试过放置contentType:“application / json”,//注意contentType defintion查看其他帖子但没什么帮助..任何人都可以提供有关如何调试此错误的指导或最好提供解决方案

错误: -

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

SUVALID.py

的回应
Just outputs the content of the python script

您好,

提交活动: -

$("#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's 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 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;
        ..................

0 个答案:

没有答案