1

The following HTML code is throwing error message.

<button name="btnSave" id="btnSave" onclick="/chbs/adm/HallNamesValidation.jsp" 
    class="btn btn-success">Save to Database</button>

The error:

Uncaught SyntaxError: Invalid regular expression flags

I am attempting to invoke HallNamesValidation.jsp without using <form action=""> because there are other <button>s on the page.

I have managed to get it working using AJAX as follows, but I'd like to know how I can make this work using my original method because with Ajax I need to add data which is an array to be processed with jsp getParameterValues():

$('#btnSave').click(function() { 
  $.ajax({ 
    url: '/chbs/adm/HallNamesValidation.jsp', 
    success: function (data) { console.log(data); } 
  }); 
});
5
  • Post the code causing the error? Commented Jan 29, 2018 at 14:52
  • Did it in original post Commented Jan 29, 2018 at 14:58
  • Got Success with workaround using ajax call but will await if there is better solution. The code is ` $('#btnSave').click(function() { ///Saving Table Data to MySQL through Ajax Call $.ajax({ url: '/chbs/adm/HallNamesValidation.jsp', success: function (data) { console.log(data); } }); });` Commented Jan 29, 2018 at 14:58
  • 2
    Hi @Raky, I've updated your question with your code. If you have more to add, please use the edit link on your post instead of the comments. Commented Jan 29, 2018 at 15:03
  • @RoddyoftheFrozenPeas, Thanks sir. Commented Jan 29, 2018 at 15:08

1 Answer 1

3

onclick expects some javascript code, so /chbs/adm/HallNamesValidation.jsp is converted as a regular expression

what you might want to do is

onclick="location.href='/chbs/adm/HallNamesValidation.jsp'"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.