Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Formularz bez przeladowania strony. Problem z przekazaniem zmiennych.
fcppl
post 10.01.2023, 12:52:35
Post #21





Grupa: Zarejestrowani
Postów: 116
Pomógł: 0
Dołączył: 11.04.2010

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


witam,

Chciałem zrobić prosty formularz bez przeładowania strony za pomocą serialize i wszystko działa OK, ale po wywołaniu skryptu nie przekazuje zmiennej Submit POST -> $_POST['unpublished'] i $_POST['published']

Jeżeli formularz ładuję bezpośrednio z products_success.php te zmienne istnieją i warunki mogą być spełnione.

Problem mam taki jak zrobić żeby te zmienne POST po wywołaniu serialize też istniały?

  1. $(document).ready(function(){
  2. $("#form_add_products").on("submit", function(event){
  3. event.preventDefault();
  4. $.post("products_success.php", $(this).serialize(), function(data){
  5.  
  6. });
  7. });
  8. });
  9.  
  10.  
  11. <form id="form_add_products" method="post" enctype="multipart/form-data">
  12.  
  13. ....
  14.  
  15. <input type="submit" name="published" value="Opublikuj" class="dropdown-item">
  16. <input type="submit" name="unpublished" value="Wycofaj" class="dropdown-item">
  17.  
  18. </form>


  1. echo = $_POST['published'];
  2. echo = $_POST['unpublished'];
  3.  
  4.  
  5. if (isset($_POST['published'])) {
  6.  
  7. echo 'publikuje';
  8.  
  9. }
  10.  
  11. if (isset($_POST['unpublished'])) {
  12.  
  13. echo 'wylaczony';
  14.  
  15. }


Ten post edytował fcppl 10.01.2023, 12:53:14
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 2.06.2024 - 22:27