Our website's select box has been updated to retrieve city options from a JavaScript array file using an ajax call request. This file is now dynamically created on a different server and then transferred to the static server where it is used to populate the select box.
While this method works well most of the time, there are occasional failures when the file becomes corrupted or is not fully transferred. This results in syntax errors within the file contents like:
var cityArray = [{SID : "15",SN : "Rajasthan",cities : [{CID : "677",CN : "Jaipur"}, //syntax error, no eol
As a result, all JavaScript on the website stops working when this file is used.
My query is how can we detect errors in the included file and revert to the old method of populating the select box options?
Thank you in advance for your help.