为什么控制台日志显示“Uncaught SyntaxError:Unexpected token ILLEGAL”错误消息?

时间:2015-11-04 05:45:09

标签: javascript

在我的html表单中,我有一个增加html表单行的javascript功能。但不知何故,它在控制台日志中返回错误:

以下是错误消息: 未捕获的SyntaxError:意外的标记ILLEGAL

以下是截图: enter image description here

以下是我正在使用的js代码:

// First serializing
dynamic collection = new { stud = stud_datatable }; // The stud_datable is the list or data table
string jsonString = JsonConvert.SerializeObject(collection);


// Second Deserializing
dynamic StudList = JsonConvert.DeserializeObject(jsonString);

var stud = StudList.stud;
foreach (var detail in stud)
{
    var Address = detail["stud_address"]; // Access Address data;
}

你能告诉我为什么它会出现在我的代码中吗?

更新: Html代码:

// add more email number
$(document).ready(function() {
    var max_fields = 4; //maximum input boxes allowed
    var wrapper = $("#emailWraper"); //Fields wrapper
    var add_button = $("#addMoreEmail"); //Add button ID

    var x = 1; //initlal text box count
    $(add_button).click(function(e) { //on add input button click
        e.preventDefault();
        if (x < max_fields) { //max input box allowed
            x++; //text box increment

            <?php $sql =  mysqli_query($link, 'SELECT * FROM contact_type'); ?>

            $(wrapper).append("<tr id='deleteEmail'><td align='right' style='padding-right:10px;'><select name='phoneExt[]'><option value=''>--select--</option><?php while($result_ctype = mysqli_fetch_array($sql)){ $ctid = (int) $result_ctype['ctid']; $all_Contact_type = inputvalid($result_ctype['contact_type']); echo " < option value = $ctid > "; echo $all_Contact_type; echo '</option>';}?></select></td><td align='right'><input type='text' name='' class='small3' id='' placeholder='Value'/><a href='#' class='remove_field'>&nbsp;X</a></td></tr>"); //add input box*/
        }
    });

    $(wrapper).on("click", ".remove_field", function(e) { //user click on remove text
        e.preventDefault();
        $("#deleteEmail").remove();
        x--;
    })
});

Firebug中的控制台: enter image description here

1 个答案:

答案 0 :(得分:1)

检查您的代码是否有一些非法字符,如空格,空格等,

检查here以获取更多答案。

有些用户建议删除代码的最后一行并重新添加它是解决此问题。