CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 07:27:53 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=f47f2f1c884955d9626778f5eeca3be788591fe4477a5376864c47dc62f97313a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22PzSxhoNfYDq2S3BvnZ2A_qxcT8kBJMP-%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d4e097ea3a7fa8-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
-
⭐⭐⭐MAKE $1000 INSTANTLY⭐⭐
Java | 5 sec ago | 0.10 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 16 sec ago | 0.10 KB
-
⭐⭐⭐Exchange Exploit T I⭐⭐
Java | 28 sec ago | 0.10 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 39 sec ago | 0.10 KB
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 50 sec ago | 0.10 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 1 min ago | 0.10 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 1 min ago | 0.10 KB
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 1 min ago | 0.10 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