0

I have a jQuery function that I would like to change to plain JavaScript.

function readZipCodes() {
     var zipCodes = [];
      $.ajax({
           url: 'data/ZipCodeDatabase.csv',
           contentType: "text/csv",
           async: false,
           success: function(text) {
                zipCodes = text.split("\n");
           }
      });
      return zipCodes;
 }

Can you please show me how to rewrite it?

BackPacker777
  • 673
  • 2
  • 6
  • 21
  • While you are at it, I would recommend rewriting it to be asynchronous. Synchronous AJAX is deprecated outside of workers, and can lock up the browser, and it's just plain lazy. – Alexander O'Mara Dec 01 '15 at 18:03
  • See [jQuery; How can I return ajax returned data? \[duplicate\]](http://stackoverflow.com/questions/25176690/jquery-how-can-i-return-ajax-returned-data) and [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) for more info. – Alexander O'Mara Dec 01 '15 at 18:04

0 Answers0