Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [CSS][JavaScript][AJAX]jQuery $.ajax Form / problem ze zmienną
toshinori
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 23.07.2009

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


Witam , czy może ktoś mi pomóc z tym problemem ?


Zmienna email nie jest pobierana z pola input gdy jest pobierana w funkcji (document ready). Działa poza funkcją ale też nie gdy zmienie pole email tylko gdy poprzez value="tymczasowa@zmienna.pl" dodam ją jako znacznik HTML . czyli działa tylko jak jest przypisana Html'em . Nigdy gdy jest zmieniona przez użytkownika.



Zamieszczam kod wraz z Formularzem .

  1. <?php
  2. <script type="text/javascript">
  3.  
  4.  
  5.  
  6. $(document).ready(function() {
  7.  
  8.  
  9.  
  10.    var emailT = function() {
  11.      
  12.      var email = $(':text').val();
  13.  
  14. alert($(':text').val());
  15.      
  16. return (email);      
  17.    };
  18.  
  19.  
  20.  
  21.  
  22.    $(':button').click(function () {
  23.  
  24.      
  25.   var email = emailT();
  26.  
  27.   // var email = $(':text').val();
  28.       var dataString = 'addr='+ email + '&action=sub';
  29.       alert (dataString);
  30.    
  31.      $.ajax({
  32.      
  33.        type: "get",
  34.        url: "maillist/index.php",
  35.        data: dataString,
  36.        success: function(data) {
  37.  
  38.              $('#faceboxDiv').empty();
  39.            var response = $(data).find('#faceboxDiv').html();
  40.            $('#faceboxDiv').hide().html('<br><br><strong>' + data + '</strong><br><br>').fadeIn();
  41.       $(".close").attr({
  42.  
  43.          
  44.             href : "index.php",
  45.  
  46.            });
  47.      
  48.         }});
  49.    
  50.    });
  51.  
  52.  
  53. }  );
  54.  
  55.  
  56. </script>
  57. ?>




  1. <form id="myForm">
  2.  
  3. Wpisz email<br/><br/>
  4.  
  5. <input type="text" name="email" id="emaill" value="" maxlength="50" />
  6. <input type="button" name="submit" value="sign up" />
  7.  
  8. </form>


Ten post edytował toshinori 23.07.2009, 09:38:49
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: 23.08.2025 - 07:02