Raky
Raky

Reputation: 906

HTML error message on button text

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); } 
  }); 
});

Upvotes: 1

Views: 303

Answers (1)

guigoz
guigoz

Reputation: 704

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'"

Upvotes: 3

Related Questions