Procházet zdrojové kódy

added error message for input

tags/V1.0
patrick před 5 roky
rodič
revize
f2ada0cba5
4 změnil soubory, kde provedl 29 přidání a 2 odebrání
  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 Zobrazit soubor

@@ -8,6 +8,10 @@
float:right;
}

#errUserName {
color: red;
}
div.verification, div.details, div.success {
height:100px;
background:lightgrey;

+ 1
- 0
html/workspace.html Zobrazit soubor

@@ -2,6 +2,7 @@

<input id="username" type=text name="user" placeholder="input name">
<button id="step1"> next </button>
<div id="errUserName"> abcdefg </div>
<div class="verification">
verification
</div>

+ 18
- 2
js/workspace.js Zobrazit soubor

@@ -24,14 +24,30 @@
console.log(mm);
});
function errUserName(msg)
{
var el = $("#errUserName");
el.html(msg);
el.fadeIn();
setTimeout(function(){
el.fadeOut();
}, 2000);
}
$(document).on("click", "#step1", function(){
var input = $("#username").val();
if ( input == "" ){
errUserName(" cannot be empty");
return;
}
$.post(mm.ajax_url, { // POST request
_ajax_nonce: mm.nonce, // nonce
action: "list_users", // action
client : 333,
client : input,
}, function(response, status, xhr){
alert(response);
alert(response.id);
}).fail(function(){
alert('network error ');
});

+ 6
- 0
member.php Zobrazit soubor

@@ -96,11 +96,17 @@ class Member{
function ajax_list_users()
{
check_ajax_referer('medal');
$client = $_POST['client'];
$url = $_POST["action"];
$response = array(
'status' => 'success',
'users' => [
1,2,3,4,5,6,7
],
'id' => $client,
'url' => $url,
);
wp_send_json($response);
}

Načítá se…
Zrušit
Uložit