我使用了来自https://www.zellerda.com/projects/jquery/tokenize的jquery multi select tokenizer jquery插件。我正在父母和老师之间开发一个PHP的邮件服务。当父类型为hrhername时,它需要进入下拉列表并点击它,它需要在文本框中。当我输入teachername时,控制台显示解析错误。当我检查响应时,我正在获取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 .' ]';
**编辑:**我是否需要在组件内进行响应?
答案 0 :(得分:1)
问题是每个字面反斜杠需要使用另一个反斜杠
进行转义\成为\\
"text" : "Abdul Hakim - Hamed - [Language and literature \\ Arabic]",