Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajax whitelist #522

Closed
NiackZ opened this issue May 22, 2020 · 2 comments
Closed

Ajax whitelist #522

NiackZ opened this issue May 22, 2020 · 2 comments

Comments

@NiackZ
Copy link

NiackZ commented May 22, 2020

Hello. First of all - thank you for your work!
I get the WhiteList from the server through AJAX and I get an error in the console + the drop-down list is empty. I was trying to do what you described in this topic.
imgur
Can you tell me where I got it wrong, please?


<input type="text" name="type_tags" value="">
<script src="../js/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.polyfills.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css" rel="stylesheet" type="text/css" />
<script>
let type_input = document.querySelector('input[name="type_tags"]'),
type_tagify = new Tagify(type_input, {
    whitelist : [],
    enforceWhitelist:true,
    maxTags:1
});

type_tagify.on('input', getWL());
async function getWL(){
  type_tagify.settings.whitelist.length = 0;
  type_tagify.loading(true).dropdown.hide.call(type_tagify);
  var newWhitelist = await take_type();
  newWhitelist = JSON.parse(newWhitelist);
  console.log('newWhitelist down');
  console.log(newWhitelist);
  type_tagify.settings.whitelist.push(newWhitelist);
  type_tagify.loading(false).dropdown.show.call(type_tagify);
}
async function take_type(){
  return await $.ajax({
    type: 'POST',
    url: 'test.php',
    data: 'qq=0'
  });
}
</script>

@yairEO
Copy link
Owner

yairEO commented May 23, 2020

console.log(newWhitelist) shows nothing? maybe you have a problem with your server

I cannot help much, the code seems fine to me...

@NiackZ
Copy link
Author

NiackZ commented May 23, 2020

console.log(newWhitelist) shows nothing?
nope,
2020-05-24_00-43-04
maybe you have a problem with your server
hm... okay, I'll see what's wrong.
Thank you
upd: u was right, error was on server, my fault

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants