Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX] Jak dział funkcja assign
gebp
post
Post #1





Grupa: Zarejestrowani
Postów: 180
Pomógł: 6
Dołączył: 10.04.2006

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


Mam

test.php
  1. <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-2" />
  2. <script type="text/javascript" src="advajax.js"></script>
  3. </head>
  4. <body>
  5. <div id="t" style=" background-color:#ffff00;" >
  6. <form actiont=t2.php method=post id="form1">
  7. <input type=text name=l1>
  8. <input type=text name=l2>
  9. <input type=submit value=zapisz>
  10. </form>
  11.  
  12. <script type="text/javascript">
  13.  
  14. advAJAX.assign(document.getElementById("form1"),
  15. onSuccess: function(obj) { document.getElementById("t").innerHTML = "ODP: " + obj.responseText; },
  16. onError: function(obj) { document.getElementById("t").innerHTML = "Error..."; }
  17. )};
  18.  
  19. </div>
  20.  
  21. </body>


t2.php
  1. <?php
  2. header("Content-Type: text/html; charset=iso-8859-2");
  3.  
  4. sleep(4);
  5. $l1=$_POST['l1'];
  6. $l2=$_POST['l2'];
  7. $suma=$l1+$l2;
  8.  
  9. echo("Wynik to".$suma);
  10.  
  11. ?>


Z tego co czytałem o ajaxie tak zbudowany formularz - skrypt powinien zwrócić mi do elementu "t" wynik z skryptu t2.php. Jednakże nic a nic się nie dzieje. Gdzie popełniłem błąd. A może nie rozumiem dziłania assign.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kriqs
post
Post #2





Grupa: Zarejestrowani
Postów: 148
Pomógł: 0
Dołączył: 31.05.2006

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


  1. <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-2" />
  2. <script type="text/javascript" src="advajax.js"></script>
  3. <script type="text/javascript">
  4.  
  5. function cze()
  6. {
  7. advAJAX.assign( document.getElementById("form1"), {
  8. onSuccess: function(obj) { document.getElementById("t").innerHTML = obj.responseText; },
  9. onError : function(obj) { document.getElementById("t").innerHTML = "Error..."; }
  10. }
  11. )
  12.  
  13.  
  14. }
  15.  
  16.  
  17.  
  18. </head>
  19. <body onload=cze()>
  20. <div id="t" style=" background-color:#ffff00;" >
  21. <form action=t2.php method=post id="form1">
  22. <input type=text name=l1>
  23. <input type=text name=l2>
  24. <input type=submit value=zapisz>
  25. </form>
  26.  
  27. </div>
  28.  
  29. </body>


miales blad w skladni assign (IMG:http://forum.php.pl/style_emoticons/default/exclamation.gif) az sie dziwie ze mi sie chcialo sprawdzac (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) polecam firebuga (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

pozdrawiam (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
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: 14.10.2025 - 06:08