Hi I have the following problem. I'm trying to access the data i query from database in javascript and then execute a function
<?php
$sql_sp1 = "{call [IR_CMS].[dbo].[usp_GetPropertyPriceAndAvail](?,?)}";
$params = array( array($ChaletID, SQLSRV_PARAM_IN),
array($BoardBasisID, SQLSRV_PARAM_IN));
$result_sp1 = sqlsrv_query( $conn, $sql_sp1, $params);
if( $result_sp1 === false)
{
echo "2. Get property price and avail - Error in query preparation/execution.\n";
die( print_r( sqlsrv_errors(), true));
}
$data_sp1 = array();
while($row_sp1 = sqlsrv_fetch_array($result_sp1, SQLSRV_FETCH_ASSOC)) {
$data_sp1[] = $row_sp1;
}
//echo '<pre>';
//print_r($data_sp1);
//echo '</pre>';
?>
<script>
availdata = <?php echo json_encode($data_sp1); ?>;
</script>
If I echo the data it produces something like this
[{"PropertyID":138,"PropertyName":"Yves","ShowAvail":"Y","PropertyStartDateID":509495,"StartDate":"2012-12-08","DurationDesc":"7 nights","Saving":null,"Price":null,"Avail":"4","LiveSeason":1,"SeasonDesc":"2012-13","BoardBasisDesc":"Catered","PropTypeDesc":"Chalet Hotel","ResortName":"Les Arcs","CountryDesc":"France","FTA":"FTA","Sole_Use":0,"IsInShorlist":0}];
but I cannot access it in the javascript. It will work if I copy and paste the data into my javascript directly, but not if I try to access it dynamically. And yes, I have done my research, I'm pretty sure this should work Any ideas whatI'm doing wrong