javascript - Populating js array in blade template -


i'm trying build javascript array of data use in flot result of php db query.

when i'm outputting numbers ($lic->users) it's fine, whenever try output string blank page in browser.

i've tried:

  • {{ $lic->companyname }}
  • "<?php echo $lic->companyname; ?>"
  • {{{ $lic->companyname }}}
  • '"'+ <?php echo $lic->companyname; ?> +'"'

but when hard-code (to say, 'companyname'), builds bar graph (& displays page) fine.

var data =  [     @foreach($licdata $lic)     {     'label': "{{ $lic->companyname }}",     'data': [                 ["{{ $lic->companyname }}", {{ $lic->users }}],                  ["{{ $lic->companyname }}", {{ $lic->emps }}]             ]     },     @endforeach ]; 

i think must quoting/escaping string in js, can't work out what, know correct syntax is?

it fault, used:
"<?php echo $lic->companyname ?>"
{{ $lic->companyname }} works, once i'd corrected underlying problem (a case-sensitivity issue).

using fiddler (which cannot recommend highly enough) found blank browser page (just white page) caused following being returned in page:

var data =  [     @foreach($licdata $lic)     {     'label': "<!doctype html <html>   <head> 

followed load of html (head tag, meta tags, css, etc...).

this result of field name (companyname) in sql having different case.
ms sql server doesn't care case, php (companyname vs companyname)!

once php/laravel creates objects out of result set, fieldnames become properties , when access them, must match in case.

always check case of php variables/objects, if framework auto-translating them records objects (or similar).


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. ? -