Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] .post w tablicy nie aktualizuje stringa
elbroth
post 10.07.2016, 11:06:22
Post #1





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

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


Cześć, mam taki kod, zmienna route powinna być zlepkiem kilku stringów. Co robię źle? Po stronie PHP wszystko działa poprawie, jest zwracany dobry JSON.


[JAVASCRIPT] pobierz, plaintext
  1. $('#getAllBuses').submit(function() { // catch the form's submit event
  2. $.ajax({ // create an AJAX call...
  3. data: $(this).serialize(), // get the form data
  4. type: $(this).attr('method'), // GET or POST
  5. url: $(this).attr('action'), // the file to call
  6. success: function(response) { // on success..
  7. var results = jQuery.parseJSON(response);
  8.  
  9. $('#buses').html("Wszystkie autobusy:");
  10. $(results).each(function(key, value) {
  11. var keyword = value.name;
  12. var route = '';
  13. $.post("app.php?action=getRoute", {city: keyword})
  14. .done(function (data) {
  15. var routes = jQuery.parseJSON(data);
  16. $(routes).each(function (key, value) {
  17. route += value.city;
  18. });
  19. });
  20. $('#buses').append('<p><b>' + value.departure + '</b> - <b>' + value.name +'</b> do <b>' + value.last_stop +'</b> (przez: ' + route + ')').html();
  21.  
  22. });
  23. }
  24. });
  25. return false; // cancel original event to prevent form submitting
  26. });
[JAVASCRIPT] pobierz, plaintext
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: 15.06.2025 - 22:22