J'utilise la méthode $ jquery ajax pour trier les données et afficher dans 3 champs, j'ai utilisé la même méthode ajax pour 3 textboxs différents, To, CC, Bcc, et je veux utiliser la méthode 1 ajax pour les données, ici tagSource: one fonction à appeler la méthode ajaxComment peut-on réutiliser la méthode jQuery ajax pour 3 fonctions?
jQuery(document).ready(function() {
jQuery("#totags").tagit({
allowSpaces: true,
tagSource: function (request, response) {
$.ajax({
type: "POST",
url: "Blog.aspx/GetName",
data: "{'match': '" + request.term + "'}",
dataType: "json",
contentType: "application/json",
success: function (data) {
console.log(data);
if (data.d != null) {
response($.map(data.d, function (item) {
return {
label: item.Name,
value: item.id,
};
}));
}
}
});
},
});
jQuery("#cctags").tagit({
allowSpaces: true,
tagSource: function (request, response) {
$.ajax({
type: "POST",
url: "Blog.aspx/GetName",
data: "{'match': '" + request.term + "'}",
dataType: "json",
contentType: "application/json",
success: function (data) {
console.log(data);
if (data.d != null) {
response($.map(data.d, function (item) {
return {
label: item.Name,
value: item.id,
};
}));
}
}
});
},
});
jQuery("#bcctags").tagit({
allowSpaces: true,
tagSource: function (request, response) {
$.ajax({
type: "POST",
url: "Blog.aspx/GetName",
data: "{'match': '" + request.term + "'}",
dataType: "json",
contentType: "application/json",
success: function (data) {
console.log(data);
if (data.d != null) {
response($.map(data.d, function (item) {
return {
label: item.Name,
value: item.id,
};
}));
}
}
});
},
});
});