JQuery Data Table Question

Bob Schneider
Bob Schneider used Ask the Experts™
on
I use data tables to display results of races that we time on a classic asp website (https://www.gopherstateevents.com/results/fitness_events/results.asp?event_type=5&event_id=883&race_id=1516).  This weekend the results of one of our bigger races showed a Data Table error until I figured out that one person's name was incorrectly entered, with a "/" inserted (ie: Johns/on).  There were no issues in the way the results were calculated and displayed everywhere except in our data tables.

Here is my question:  Are there other characters that will prevent JQuery data tables rendering?  Also, should I build some error trapping in to prevent these characters (ie: Replace(FirstName, "/", "").  Seems like a lot of processing for something that is so unlikely to happen?

Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Hey Bob,

Often, any bug in software is something that is 'unlikely to happen', but it only needs it to happen once, and your app is broken, so the problem should be addressed. Generally speaking, you should validate data on input, so whenever the data comes in (import / user entry etc) it should be validated and cleaned at that point.

The slash in particular is a special character, and with any special character, you usually have the option to 'escape' it, often with a backslash. I can't tell you specifically how to do that in your case but when you create your JSON data, you should have an option to escape the data. It won't remove the slash, but it will prevent your app from breaking. Once it's slashified, your data comes across like so:

Johns\/on

But it should still display as Johns/on
leakim971Multitechnician
Top Expert 2014

Commented:
I figured out that one person's name was incorrectly entered, with a "/" inserted (ie: Johns/on).  There were no issues in the way the results were calculated and displayed everywhere except in our data tables.

I tried to reproduce without success.
Data is data, until producing invalid JSON, you should not have any issue. For some reason your JSON was not valid and it throw a JavaScript error, it's not about DataTables but about producing valid JSON data.
Bob SchneiderCo-Owner

Author

Commented:
Thank you both!
Hi,

I just want to say that if you use Datatables filter or Yadcf filter you may need to select the appropriate settings
for example you can set the value to have HTML or not
You may also need specific ordering  pluging when dealing with date and special characters

So you need to check with all Datatables plugins you are using and often check the broswer console for errors ...
right click / inspect check console tab
You have 3 errors on your page  uncaught SyntaxError: Unexpected token '<'

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial