Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [AJAX] Undefined
emajl22
post
Post #1





Grupa: Zarejestrowani
Postów: 273
Pomógł: 21
Dołączył: 28.11.2010

Ostrzeżenie: (10%)
X----


Mam sobie skrypt:

  1. function postForm() {
  2. $("#loading").show("fast");
  3. $.post("link", $("#ajaxForm").serialize(),
  4. function(data) {
  5. $("#loading").hide("fast");
  6. $("#comments").append(
  7. '<div class="comment"><div>'+data.ccc+''+
  8. '</div></div>'
  9. );
  10. }, "json");


i niby działa, skrypt dodaje rekordy do bazy bez przeładowania strony, ale zaraz po dodaniu zamiast pokazywać ostatnio dodany rekord, pokazuje mi "Undefined" :/ nie mam pojęcia co może być nie tak, a z ajaxem mam pierwszy raz styczność. Jeśli to w ogóle jest ajax (IMG:style_emoticons/default/biggrin.gif)

proszę o pomoc
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




A zwracasz te ccc spowrotem do skryptu?
Go to the top of the page
+Quote Post
emajl22
post
Post #3





Grupa: Zarejestrowani
Postów: 273
Pomógł: 21
Dołączył: 28.11.2010

Ostrzeżenie: (10%)
X----


nie wiem.. nie znam się na tym w ogóle, ale chyba tak...

  1. echo json_encode($comment);
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




no a $comment zawiera indeks o nazwie ccc?
Go to the top of the page
+Quote Post
emajl22
post
Post #5





Grupa: Zarejestrowani
Postów: 273
Pomógł: 21
Dołączył: 28.11.2010

Ostrzeżenie: (10%)
X----


mam tak:

  1. <textarea id="ccc" name="ccc" colspan="2" cols="73" rows="7"></textarea>


  1. $commentt['comment'] = $_POST['ccc'];
  2.  
  3. // query
  4. echo json_encode($commentt);
  5.  


Ten post edytował emajl22 11.03.2011, 15:27:15
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




$comment nie ma ccc tylko ma comment.
No nie widzisz tego?
Go to the top of the page
+Quote Post
emajl22
post
Post #7





Grupa: Zarejestrowani
Postów: 273
Pomógł: 21
Dołączył: 28.11.2010

Ostrzeżenie: (10%)
X----


jej (IMG:style_emoticons/default/ohmy.gif)
Go to the top of the page
+Quote Post

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: 22.08.2025 - 16:09