| float:right; | float:right; | ||||
| } | } | ||||
| #errUserName { | |||||
| color: red; | |||||
| } | |||||
| div.verification, div.details, div.success { | div.verification, div.details, div.success { | ||||
| height:100px; | height:100px; | ||||
| background:lightgrey; | background:lightgrey; |
| <input id="username" type=text name="user" placeholder="input name"> | <input id="username" type=text name="user" placeholder="input name"> | ||||
| <button id="step1"> next </button> | <button id="step1"> next </button> | ||||
| <div id="errUserName"> abcdefg </div> | |||||
| <div class="verification"> | <div class="verification"> | ||||
| verification | verification | ||||
| </div> | </div> |
| console.log(mm); | console.log(mm); | ||||
| }); | }); | ||||
| function errUserName(msg) | |||||
| { | |||||
| var el = $("#errUserName"); | |||||
| el.html(msg); | |||||
| el.fadeIn(); | |||||
| setTimeout(function(){ | |||||
| el.fadeOut(); | |||||
| }, 2000); | |||||
| } | |||||
| $(document).on("click", "#step1", function(){ | $(document).on("click", "#step1", function(){ | ||||
| var input = $("#username").val(); | |||||
| if ( input == "" ){ | |||||
| errUserName(" cannot be empty"); | |||||
| return; | |||||
| } | |||||
| $.post(mm.ajax_url, { // POST request | $.post(mm.ajax_url, { // POST request | ||||
| _ajax_nonce: mm.nonce, // nonce | _ajax_nonce: mm.nonce, // nonce | ||||
| action: "list_users", // action | action: "list_users", // action | ||||
| client : 333, | |||||
| client : input, | |||||
| }, function(response, status, xhr){ | }, function(response, status, xhr){ | ||||
| alert(response); | |||||
| alert(response.id); | |||||
| }).fail(function(){ | }).fail(function(){ | ||||
| alert('network error '); | alert('network error '); | ||||
| }); | }); |
| function ajax_list_users() | function ajax_list_users() | ||||
| { | { | ||||
| check_ajax_referer('medal'); | |||||
| $client = $_POST['client']; | |||||
| $url = $_POST["action"]; | |||||
| $response = array( | $response = array( | ||||
| 'status' => 'success', | 'status' => 'success', | ||||
| 'users' => [ | 'users' => [ | ||||
| 1,2,3,4,5,6,7 | 1,2,3,4,5,6,7 | ||||
| ], | ], | ||||
| 'id' => $client, | |||||
| 'url' => $url, | |||||
| ); | ); | ||||
| wp_send_json($response); | wp_send_json($response); | ||||
| } | } |