I have a list of zip-codes that I need to search trough using jQuery.
I have the zip-codes in a CSV file like this:
2407;ELVERUM 2425;TRYSIL 2427;TRYSIL 2446;ENGERDAL 2448;ENGERDAL
The list is pretty big, over 4000 entries, zip-code and corresponding city.
What the fastest way to search trough the list in the browser? JSON? If that's the case, how can I convert the list to JSON or another format if better?
{ "2407": "ELVERUM", "2425": "TRYSIL" }
Can someone show me the mest way to do this?
Update
Would it be possible/faster to search the loaded CSV file with just Regex?
Update2 I'm looking for an exact match, and it's only going to search when it has 4 numbers.
Update3 Here is my code:
$('#postnummer').keyup(function(e) {
if($(this).val().length == 4) {
// Code to search the JSON for an exact match.
}
});
$.getJSON("data.json",function(data){
});
Can anyone show me using this code?