Javascript in PHP file which outputs JSON -
is there way use javascript
code inside php
file uses header('content-type: application/json');
output in json
format?
edit: i'm trying change color of css class when $est = 'crest'
but javascript
code printed along. javascript
part inside comment /*here*/
<?php header('content-type: application/json'); $vs=array(); $vs1=array(); include("json/connectorcl.php"); if ((isset ($_get['ty'])) , (isset ($_get['est']))){ $nprocesso = $_get['ty']; $est = $_get['est']; if ($est == 'crest') { $query2 = "select * patern crest='1'"; $result2 = oci_parse($connect, $query2); oci_execute($result2); /*here*/ echo "<script type='text/javascript'> $('.time-title').css({'color':'blue'});</script>"; /*here*/ } else { $query2 = "select * patern"; $result2 = oci_parse($connect, $query2); oci_execute($result2); } while($res2 = oci_fetch_array($result2) , $res5 = oci_fetch_array($result5)) { $a++; $vs['id']= $a; $vs['title']='vs - '.$res2['categoria_desc']; $vs['startdate']=$res2['datamsg']; $vs['enddate']=$res2['datamsg']; $vs['description']= '1ºh - '.$res2['valor'].'| max - '.$res5['maxval'].'| min - '.$res5['minval'].'| avg - '.$res5['avgval']; $vs['date_display']='ho'; $vs['icon']='plus_blue.png'; $vs['importance']='30'; $b=$a; array_push($vs1,$vs); } echo str_replace(array('[', ']'), '', htmlspecialchars(json_encode($vs1), ent_noquotes));}}
if understand question right, yes can.
example, json.php
header('content-type: application/json'); echo json_encode(array('text' => 'im json baby'));
Comments
Post a Comment