0
我使用jQuery的多選擇tokenizer jquery插件從https://www.zellerda.com/projects/jquery/tokenize。我正在開發一個父母和老師之間的PHP郵件服務。當父類型教師名稱,它需要在下拉並點擊它時,它需要在文本框中。當我鍵入教師名稱時,控制檯顯示解析錯誤。當我檢查響應時,我得到了json數組。請幫助我。jquery tokenizer中的json響應的解析錯誤
的Jquery:
<link rel="stylesheet" type="text/css" href="../js/jquery_multipleSelect/jquery.tokenize.css" />
<script type="text/javascript" src="../js/jquery_multipleSelect/jquery.tokenize.js">
</script>
$('#to_message').tokenize({
datas: "module/parents/communication/view_teacher_search.php?action=new_message",
contentType: "application/json; charset=utf-8",//not working when commented
//dataType: "json",//without commented also not working
autosize: true,
nbDropdownElements: 30,
onAddToken: function(value, text, e){
$("#compose_message").append('<input type="hidden" name="teacher_ids[]" id="'+value+'" value="'+value+'" >');
},
onRemoveToken: function(value, e){
$("#"+value).remove();
}
});
view_teacher_search.php
$db->query($getStudentsListQuery);
//$selStudents = '';
while($row = $db->get_row())
{
$data .= ' {
"text" : "' .$row[1] . ' - '. $row[2] .' - ['. $row[3] .']",
"value" : "'.$row[0].'"
},';
if($action == 'reply_message'){
break;
}
}
$new_userdata = substr_replace($data,"",-1);
echo '[ '. $new_userdata .' ]';
**編輯:**我是否需要讓內部元件的反應?
反斜槓\需要轉義\\ – devnull69
你能回答,因爲答案的評論進行轉義。我知道了 – Techy