Faridul Khan Faridul Khan - 4 months ago 23
Javascript Question

ivirabyan/jquery-mentions how to check ajax request respone

I am using ivirabyan/jquery-mentions in my project. i can do ajax request, but the problem is how can i use the response

$('textarea.mentions').mentionsInput({
source: function( request, response ) {

$.ajax({
url: rootPath() + "user/tagFriends/" + request.term,
type: "GET",
dataType: "json",

success: function(data){
alert(data);
// found data here
}
});
},
showAtCaret: true

});


Thanks in advance.

Answer

You can try this code, it may work

$('textarea.mentions').mentionsInput({
source: function( request, response ) {

    $.ajax({
        url: rootPath() + "user/tagFriends/" + request.term,
        type: "GET",
        dataType: "json",

        success: function(data){
          response(data);
          // Just add this line
        }
    });
},
showAtCaret: true

});