I am in a pickle with this problem.
I have a text area and I want to click on a button to
- transform the address text into uppercase
- loop through the data I've acquired from an API and check to see if the addresses match up.
I've been working on it for a couple of days searching through stackoverflow questions and the Mozilla docs for answers. I've tried just doing step one and I've been getting Uncaught SyntaxError: Unexpected end of input errors. But I believe my syntax is correct.
HTML
<form>
<p>Check to is if street light service has already been requested</p><br>
<input type="text" name="service" id="chiService">
<button type="button" id="btn">Try it</button>
</form>
Javascript
$.ajax({
url: "https://data.cityofchicago.org/resource/h5ea-dn36.json",
type: "GET",
data: {
"$limit" : 4,
"$$app_token" : "APP_TOKEN"
}
}).done(function(data) {
var el = document.getElementById("btn");
function serviceFunction(myData){
var userStreetAddress = document.getElementById('chiService').value;
userStreetAddress = userStreetAddress.toUpperCase();
/*for(var i = 1; i < myData.length; i++){
if(myData.street_address[i] == userStreetAddress){
console.log('its working!');
}
*/}
alert(userStreetAddress);
};
el.addEventListener("click", serviceFunction(data), false);
});//end of ajax function