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.
$('#getAllBuses').submit(function() { // catch the form's submit event
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: $(this).attr('method'), // GET or POST
url: $(this).attr('action'), // the file to call
success: function(response) { // on success..
var results = jQuery.parseJSON(response);
$('#buses').html("Wszystkie autobusy:");
$(results).each(function(key, value) {
var keyword = value.name;
var route = '';
$.post("app.php?action=getRoute", {city: keyword})
.done(function (data) {
var routes = jQuery.parseJSON(data);
$(routes).each(function (key, value) {
route += value.city;
});
});
$('#buses').append('<p><b>' + value.departure + '</b> - <b>' + value.name +'</b> do <b>' + value.last_stop +'</b> (przez: ' + route + ')').html();
});
}
});
return false; // cancel original event to prevent form submitting
});