Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX]ajax nie dziala
benzulli
post
Post #1





Grupa: Zarejestrowani
Postów: 112
Pomógł: 0
Dołączył: 3.07.2013

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


Kod
var menuId = "asd";
$(document).ready(function() {
        $.ajax({
          url: "kanwa.php",
          type: "POST",
          data: {id : menuId},
          dataType: "html"
        });
        });
        alert(<?php echo $_POST['id']; ?>);


Post zwraca pustą zmienną

Ten post edytował benzulli 29.11.2015, 17:33:46
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
casperii
post
Post #2





Grupa: Zarejestrowani
Postów: 681
Pomógł: 28
Dołączył: 14.08.2014

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


Czemu nie zrobisz czegoś na ten styl:


  1. var menuId = "asd";
  2. $.getJSON('ajax.php', {input: ""+menuId+""}, function(data) {
  3. $('input[name="id"]').val(data.id);
  4. });



  1. <input type="text" name="id" value="">



Ajax.php:

  1. $a->id = $result->id;
  2. echo json_encode($a);
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: 16.10.2025 - 23:46