Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX] Nie działa żądanie
Fred1485
post
Post #1





Grupa: Zarejestrowani
Postów: 361
Pomógł: 22
Dołączył: 10.02.2015

Ostrzeżenie: (0%)
-----


Mam bardzo prosty skrypt:

  1. $('#submit').on('click', function() {
  2. var login = $('input[type=text]').val();
  3. var password = $('input[type=password]').val();
  4.  
  5. $.ajax({
  6. type: "POST",
  7. url: "zam.php",
  8. dataType: "json",
  9. data: {
  10. login: login,
  11. password: password
  12. },
  13. success: function(response) {
  14. alert(response);
  15. },
  16. error: function() {
  17. alert('blad');
  18. }
  19.  
  20. });
  21.  
  22. });]


  1. <div id="loginform">
  2. <input type="text" class="input" name="login"/>
  3. <input type="password" class="input" name="password"/>
  4. <input id="submit" type="submit" name="submit" value="zaloguj!"/>
  5. </div>


a w PHP najprostsze:
  1. $login = $_POST['login'];
  2. $password = $_POST['password'];
  3.  
  4. if(strlen($login) < 5 || strlen($password) < 5) {
  5. $otp = json_encode(['type' => 'success', 'text' => 'ok']);
  6. die($otp);
  7. }
  8. else {
  9. $otp = json_encode(['type' => 'error', 'text' => 'blad']);
  10. die($otp);
  11. }


Zawsze wyskakuje błąd, nazwa pliku php na pewno dobra...


Ten post edytował Fred1485 30.05.2015, 12:14:09
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 00:19