CARVIEW |
Select Language
HTTP/2 200
date: Fri, 10 Oct 2025 20:14:35 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=f2b94d3441d53aa4ed8b249cdc2df559311e022b39676d922611b5fdf9707e3da%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22L5n3k97__vUL2PGlCx4LYpC7OTT4HfZQ%22%3B%7D; HttpOnly; Path=/
cf-ray: 98c8c8edb9239dfa-BLR
Select2 With Ajax Data Attributes in jQuery - Pastebin.com
SHARE
TWEET

Select2 With Ajax Data Attributes in jQuery
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#employee_id').select2({
- placeholder: 'Select Employee Type',
- width: '100%',
- allowClear: true,
- ajax: {
- url: backend_url + '/employee/get_employee',
- dataType: 'json',
- delay: 300,
- type: 'POST',
- data: function(params) {
- return {
- search: params.term, // search term
- // _token: $('meta[name="csrf-token"]').attr('content'),
- // _method: 'POST',
- emp_type: $('#emp_type').val(),
- department: $('#department').val(),
- page: params.current_page,
- }
- },
- processResults: function(data, params) {
- params.current_page = params.current_page || 1;
- var res = data.data.map(function(item) {
- return {
- id: item.id,
- text: item.name,
- max_advanced: item.max_advanced
- };
- });
- return {
- results: res,
- pagination: {
- more: (params.current_page * 10) < data.total
- }
- };
- },
- cache: true
- },
- templateResult: function(data) {
- if (!data.id) {
- return data.text;
- }
- var $result = $('<span>' + data.text + '</span>');
- $result.attr('data-salary', data.max_advanced);
- return $result;
- },
- templateSelection: function(data) {
- if (!data.id) {
- return data.text;
- }
- return data.text;
- },
- }).on('select2:select', function(event) {
- // On Change Event Code Here Selected Data
- });
- // Get Selected Data Attribute Value Get
- $("#employee_id").select2('data')[0].max_advanced
Advertisement
Add Comment
Please, Sign In to add comment
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ 4
JavaScript | 7 sec ago | 0.24 KB
-
⭐✅ Swapzone Glitch ✅ Working⭐⭐⭐ R
JavaScript | 18 sec ago | 0.24 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ B
JavaScript | 29 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ K
JavaScript | 30 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ Y
JavaScript | 40 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ G
JavaScript | 41 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ C
JavaScript | 52 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ I
JavaScript | 54 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand