Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/18/2019 in all areas

  1. One thing you shouldn't do is run an outer query then loop through the results running further queries. It is inefficient and heavy on resources. You should use JOINS to get all the data you need in a single query
    1 point
  2. Trying to inject code directly into JS like in your original post is risky. Someone may be able to use it to inject html/js into the document. The better approach is to insert the JSON data into your HTML document (with normal HTML escaping applied) and then parse it. A hidden input is one way to do that, another way is with a data attribute which is what I typically do (jQuery will auto-parse json data attributes). <script src="/js/something.js" data-rs="[[1,2,3],[2,3,4],[3,4,5]]"></script> var rs = $(document.currentScript).data('rs'); document.currentScript needs to be read during the initial script load, you can't put it in an event handler for example. According to caniuse.com, it also doesn't work in IE. If that's a concern, there are alternative methods / polyfills that exist.
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.