I am using laravel blade format for my html and I am passing multiple php variables to javascript functions. Now the issue the variables being passed to javascript function could have special characters. Now I want to the javascript function to be as follows:
what I want:
jsFunction("argument1","argument2","argument3")
what I get:
jsFunction('argument1','argument2','argument3')
Now my blade format code is:
<a href="#" onclick="displayBannerInvoice('{{$bannerProperty->property_id}}','{{ $bannerProperty->id }}','{{$bannerProperty->end_date}}','{{$bannerProperty->no_of_days}}','{{$bannerProperty->total}}','{{$bannerProperty->vat_percentage}}')"></a>
onclick
and string concatenation which is very fragile and error-prone in this case, considerjson_encode
ing the data and storing the result in JavaScript variables. Then yourclick
event handler set byaddEventListenter
or ... can easily read the data. – Vohuman Mar 9 at 8:01