Преглед на файлове

added error message for input

tags/V1.0
patrick преди 5 години
родител
ревизия
f2ada0cba5
променени са 4 файла, в които са добавени 29 реда и са изтрити 2 реда
  1. +4
    -0
      css/workspace.css
  2. +1
    -0
      html/workspace.html
  3. +18
    -2
      js/workspace.js
  4. +6
    -0
      member.php

+ 4
- 0
css/workspace.css Целия файл

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;

+ 1
- 0
html/workspace.html Целия файл



<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>

+ 18
- 2
js/workspace.js Целия файл

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 ');
}); });

+ 6
- 0
member.php Целия файл

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);
} }

Loading…
Отказ
Запис