Question

Full Code Here: http://pastebin.com/qQpsTjsR

I've been trying to submit a post form to send off an email; I've gotten the form to save something to the localstorage for the browser. However now I've had to simulate a submit with the action changed in the javascript; which when called seems to simple give me the Syntax Exception, at line 1, even though there's no javascript at line 1? I've checked in the inspect menu and the brackets seem to be fine. I've also ran it though JSLint, hence the 'use strict' statements littered around.

I cant seem to pinpoint the issue; which is bothering me...A second pair fo eyes would be great to find the issue; or perhaps it's something I didn't know before? (Pretty new to Javascript in terms of debugging..)

This is the Javascript embeded, but at the top of the file you'll find the full file:

function showForms() {
    'use strict';
    $('.primaryForm').fadeIn(700);
}
function submitForm() {
    'use strict';
     SetItem('username', $('#username').val());
     $('.primaryForm').action = "download.php";
     $('.primaryForm').submit();
}
function intro2TypeWrite() {
     'use strict';
     $('.intro2').typewrite().delay(8750).fadeOut(700);
     setTimeout(showForms, 9450);
}
function intro2Show() {
    'use strict';
     $('.intro').delay(5000).fadeOut(700);
     setTimeout(intro2TypeWrite, 5700);
}
$(document).ready(function () {
     'use strict';
     $('.intro').typewrite({
         'callback': intro2Show()
     });
});
Was it helpful?

Solution

I can't tell which one; but in the end I found a better solution to my whole issue after some research into the submitting process of a form and found that instead of using the on click event of a submit input; I could use the on submit event on the form.

My findings showed that in situation of wanting to forward with the included post data, that the submit would run the javascript in the onsubmit event before the page is redirected to the action page.

so the change would be:

function submitForm() {
    'use strict';
     SetItem('username', $('#username').val());
     $('.primaryForm').action = "download.php";
     $('.primaryForm').submit();
}

To...

function submitForm() {
     SetItem('username', $('#username').val());
}

I also removed the 'use strict' stataments from ALL of my functions; after reading through the article posted by gregjer and seeming as it caused errors to stop bad coding (Which I am unfortunately a likely candidate for such issues.)

In the end, a simple swap to onsubmit, OR the removal of use strict fixed the issue!

After receiving these errors in college again, even with the above changes; I found that the javascript:void caused the unexpected end of the input, changing the action to another file such as...download.php/html fixed it as it gave an end to the script it seems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top