As see for the first and the third row all fields filled, for the second row some fields left blank.
Filled values with
$.post("__php_file.php", { 'number_of_input_row': number_of_input_row, 'date_day': date_day, 'date_month': date_month, 'date_year': date_year, 'currency': currency }, function(data, success) {
$('#currency_load1').html(data[0].FinalCurrencyRate);
$('#currency_load2').html(data[1].FinalCurrencyRate);
$('#currency_load3').html(data[2].FinalCurrencyRate);
}, "json");
send to php file, process and get such php array
Array
(
[0] => Array
(
[CurrencyAbbreviation] => AUD
[DateOfCurrencyRate] => 2013-07-11
[NumberOfInputRow] => 1
[FinalCurrencyRate] => 0.506
)
[2] => Array
(
[CurrencyAbbreviation] => CAD
[DateOfCurrencyRate] => 2013-07-25
[NumberOfInputRow] => 3
[FinalCurrencyRate] => 0.516
)
)
json array is this
{
"0":{"CurrencyAbbreviation":"AUD","DateOfCurrencyRate":"2013-07-11","NumberOfInputRow":"1","FinalCurrencyRate":"0.506"},
"2":{"CurrencyAbbreviation":"CAD","DateOfCurrencyRate":"2013-07-25","NumberOfInputRow":"3","FinalCurrencyRate":"0.516"}
}
So far all ok. But below is described problem
Get back results and display here
<div id="currency_load1"></div>
<div id="currency_load2"></div>
<div id="currency_load3"></div>
However get displayed only FinalCurrencyRate
for AUD
or [0] => Array
.
Question is: what need to correct to get displayed also FinalCurrencyRate
from [2] => Array
? As you see in php such array presents, but is not passed to json...
If fill all fields for the second row, then get displayed all three arrays.
Update Tried this
$('#currency_load1').html(data[0].FinalCurrencyRate);
$('#currency_load2').html("test to check");
$('#currency_load3').html(data[2].FinalCurrencyRate);
And all works. As understand within jquery
need to create condition like if FinalCurrencyRate is empty, then $('#currency_load2').html("0");
? But why such json/jquery behavior?