I'm trying to post back some form fields back to our ldap connector. I can get both groups and members from within each group, but I'm not getting any response when I try to post back a user.
To clarify the steps a bit
1) The user clicks 'Load Groups'. That talks to our LDAP connector. That then populates all of our companies ldap croups.
2) When a user clicks the group, it loads all the users for that group.
3) I have button that when clicked opens the modal where a form lives.
4) I'm sure i'm missing something super simple.
- //Display groups
- $(function displayGroupItems() {
- $('#ldap-tab').click(function(event) {
- $.ajax({
- url: 'ldap/groups',
- method: 'GET',
- dataType: 'json',
- success: function(data) {
- $.each(data.groups, function(i, dn) {
- output = $('<li><a id="groupsList" class="panel-block dn-class">' + dn.dn + '</a></li>');
- append = $(output).appendTo('#groupSearchUl');
- });
- }
- })
- });
- });
- //Display members of the selected group
- $(function displayMemberItems() {
- var textclass;
- $(document).on('click', '.dn-class', function(event) {
- textclass = $(this).text().replace(/=/g, '%3D').replace(/,/g, '%2C');
- $.ajax({
- url: 'ldap/members/' + textclass,
- method: 'GET',
- dataType: 'json',
- success: function(pull) {
- users = $('#userSearchUl').html(
- pull.members.map(function(uid) {
- return '<li><a class="panel-block" id="userList">' + uid.split(',')[0] + '</a></li>'
- }).join("")
- );
- }
- })
- });
- });
- //TROUBLE AREA//
- //LDAP Form Add
- $(function addMember() {
- var textclass;
- var username = $('#addUID').val();
- $('.dn-class').on('click', function(event) {
- textclass = $(this).text().replace(/=/g, '%3D').replace(/,/g, '%2C');
- });
- $("#userSubmit").on('submit', '#addUserForm', function(event) {
- $.post("/ldap/members/" + textclass + '/' + username)
- // var textclass;
- // $(document).on('click', '.dn-class', function(dn) {
- // textclass = $(this).text().replace(/=/g, '%3D').replace(/,/g, '%2C');
- // });
- // $.ajax({
- // url: '/ldap/members/,
- // method: 'POST',
- // dataType: 'json',
- // success: function(pull) {
- // alert('User added!')
- // }
- // })
- });
- });
- //LDAP Form Remove
- $(function addMember() {
- $(document).on('submit', '#addUserForm', function(event) {
- $.ajax({
- url: 'ldap/members/delete' + textclass,
- method: 'DELETE',
- dataType: 'json',
- success: function(pull) {
- alert('User added!')
- }
- })
- });
- });
The html for form lives in a modal.
- <div class="modal" id="modal-add">
- <div class="modal-background"></div>
- <div class="modal-card">
- <header class="modal-card-head">
- <p class="modal-card-title">Add Member</p>
- <button class="delete" aria-label="close"></button>
- </header>
- <section class="modal-card-body">
- <form id="addUserForm" class="form-horizontal well field has-addons" data-async data-target="#add-modal">
- <p class="control">
- <a class="button is-static" >
- uid=
- </a>
- </p>
- <div class="control">
- <input id="addUID" type="text" class="input"></input>
- </div>
- </form>
- </section>
- <footer class="modal-card-foot">
- <button type="button" class="button is-warning cancel" data-dismiss="modal">Cancel</button>
- <button type="submit" id="userSubmit" class="button is-info">Add</button>
- </footer>
- </div>
- </div>
Thanks everyone.