My goal for my code is to execute a json query request using a textfield to designate the location it is a quick search based text searching a specific website that is different from the location
eg: if i type in www.calsolum/abc i want it to search the website calsolum for 3 json files:
'a', 'ab', 'abc' the last one being the actual json file
my index file looks like this
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script src="jquery.js"></script>
<script src="script.js"></script>
<input type="text" id="location" onkeyup="myFunction()">
<body>
</body>
</html>
the script.js looks like this
var myFunction = function(event) {
var payload = {location: $(this).val()};
var jqxhr = $.getJSON('/location', payload);
jqxhr.done(function(data) {
console.log(data);
});
};
// jQuery on DOM ready
$(function() {
$("#location").keyup(myFunction);
});
So far it seems as though i get the right requests made but going from the errors the program is looking in the wrong location Any help would be greatly appreciated. If any clarification is required do not hesitate to ask.
EDIT2: so i've implemented the edits suggested and my new error when running it is
Uncaught TypeError: Cannot call method 'toLowerCase' of undefined
and
GET http://mobile.sheridanc.on.ca/location?location=http%3A%2F%2Fwww.sightlineinnovation.com%2Fsyst35288%2FAPI%2Fv1.0%2Fexchanges%2FWSA 404 (Not Found)
xinside a function. It's a local variable, so it's not available outside the function.