0

I am getting an "unexpected end of input" error on the last line below and if I keep removing the last line one at a time, the error prevails at the last line. I am trying this only with chrome.

I am using notepad++ and that doesn't throw up any errors or suggestions. I tried jedit but I am not too sure if any syntax checking is active or not in either case. N++ gives me autocomplete suggestions though.

Any idea what is wrong with this. The AJAX did complete twice while testing but this suddenly stopped working. Can't figure out what broke this.

  <script type="text/javascript">

function postevac()
{
    var location = document.getElementById("location").value ;
    var nameno = document.getElementById("Nameno").value ;
    var resources = document.getElementById("resources").value ;
    var persons = document.getElementById("persons").value ;
    var x  = new XMLHttpRequest();

    x.open("post", "http://localhost:5984/ch", true) ;

    x.setRequestHeader("Content-type", "application/json") ;

    var y = {
            "location" : location ,
            "nameno" : nameno ,
            "resources" : resources ,
            "persons" : persons ,

        } ; 

    x.send(JSON.stringify(y)) ;


</script>
1
  • 1
    You might try using tools like JSHint or ESLint to help you find and fix such issues. Commented Dec 6, 2015 at 16:41

1 Answer 1

5

add } before the last </script> you need to close the function

Sign up to request clarification or add additional context in comments.

1 Comment

Awww , this is so embarassing. I took a potty break and was wondering on my seat that javascript is something that simply likes to not work and somehow the entire world has gottten it wrong.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.