ich ein Datumsbereich Formularfeld tue, hier console.log (fname) bedeutet i alle Werte, und ich möchte in einer Tabelle td diesen Wert anhängen, ich versuche, wie dieser Methode, aber es nicht funktioniert, wie ich diesen Wert in tdWie Sie den Wert in der Tabelle anhängen
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control pull-right" id="reservation">
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#reservation").on("change", function() {
var reservation = $(this).val();
$.ajax({
type: 'post',
url: 'date-range.php',
data: {
logindate: reservation,
},
success: function(data) {
var res = jQuery.parseJSON(data); // convert the json
console.log(res);
if (res['status'] == "success") {
var htmlString = '';
$.each(res['data'], function(key, value) {
htmlString += '<tr>';
var ssm_id = value.ssm_id; // here i got ssmid
htmlString += '<td>' + value.ssm_id + '</td>';
$.ajax({
type: 'post',
url: 'config/functions.php',
data: {
ssm_id: ssm_id,
},
success: function(fname) {
console.log(fname); //here i got all names
// kani
// mahi
// kogila like this ans it will come console.log(fname),i want appent this value in hmlString+='<td>'+fname+'</td>';
htmlString += '<td>' + fname + '</td>'; // here value is not appending,nothing is happen
}
});
htmlString += '<td>' + 'Muthuraja' + '</td>';
htmlString += '<td>' + '20-05-2016' + '</td>';
htmlString += '<td>' + 'status' + '</td>';
htmlString += '<td>' + value.source + '</td>';
htmlString += '<td>' + "<span style='color:green'>View Profile</span>" + '</td>';
htmlString += '</tr>';
});
$('#datatable-editable > tbody').empty().append(htmlString);
} else {
$('#datatable-editable > tbody').empty().append("<center style='height:100px;padding-top:36px;color:red;font-size:17px;'><b>No matching records found</b></center>");
}
}
});
});
});
</script>
functions.php
<?php
$ssm_id = $_POST['ssm_id'];
if(!empty($ssm_id)){
echo firstname($ssm_id);
}
function firstname($id)
\t {
\t \t $f="SELECT firstname FROM register WHERE matri_id='$id'";
\t \t $rr=mysql_query($f);
\t \t while($row=mysql_fetch_array($rr))
\t \t \t {
\t \t \t \t $firstname = $row['firstname'];
\t \t \t }
\t \t \t return $firstname;
\t }
?>
Ihre 'ajax' innen' success' Betrieb des ersten 'ajax' funktioniert nicht richtig, wie Sie mit Ihrer Arbeit fort Werte' htmlString' anhängt, ohne für die Fertigstellung der 'ajax' innen' success' zu warten –
Wie kann man das ???? möglich bedeutet update Ihre Antwort –
Warum verwenden Sie nicht Join statt zwei Ajax Anruf – Vinie