I have this javascript:
function updatePage() {
if (request.readyState == 4)
if (request.status == 200)
var data = JSON.parse(request.responseText);
update_select($('select[name=island_name]'), data);
else if (request.status == 404)
alert("Request url does not exist");
else
alert("Error: status code is " + request.status);
}
But I keep getting aUncaught SyntaxError: Unexpected token if error which halts my script. Any ideas?
You’re missing a bunch of braces, and on the
update_select()line, it is causing a problem. The braces aren’t strictly required for most of these blocks, but because you are attempting to execute two statements in the firstif()you’ll need them. Best to put them in everywhere.