0

I used jquery multi select tokenizer jquery plugin from https://www.zellerda.com/projects/jquery/tokenize. I am developing a mail service in php between parents and teachers.When a parent type teachername,it needs to come in dropdown and on clicking it ,it needs to be in the textbox.When I type teachername,the console is showing parse error.When I check response,I am getting json array.Please help me.

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 .' ]'; 

SCreen shot

**EDIT:**Should I need to make the response inside component??

2
  • The backslash \ needs to be escaped \\ Commented Oct 22, 2015 at 7:21
  • Can you answer the comment as answer.I got it Commented Oct 22, 2015 at 7:37

1 Answer 1

1

The problem is that every single literal backslash needs to be escaped using another backslash

\ becomes \\

"text" : "Abdul Hakim - Hamed - [Language and literature \\ Arabic]",
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.