Php to json does not pass all arrays (or json does not display all received values) -


input form fields

as see first , third row fields filled, second row 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 php file, process , 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 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 ok. below described problem

get results , display here

<div id="currency_load1"></div> <div id="currency_load2"></div> <div id="currency_load3"></div> 

however displayed finalcurrencyrate aud or [0] => array.

question is: need correct displayed finalcurrencyrate [2] => array? see in php such array presents, not passed json...

if fill fields second row, displayed 3 arrays.

update tried this

$('#currency_load1').html(data[0].finalcurrencyrate); $('#currency_load2').html("test check"); $('#currency_load3').html(data[2].finalcurrencyrate); 

and works. understand within jquery need create condition if finalcurrencyrate empty, $('#currency_load2').html("0");? why such json/jquery behavior?


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -