I have a simple form with a "Submit" button and an additional "Add" button in blade template. On form submit there is an ajax callback to a controller which validates provided value. Based on the returned result from the controller, I'd like to change the "Add" button onClick event. Here is blade snip:
<button id="theId" type="button" >Add</button>
Relevant ajax pice:
$.ajax({
...
success: function(result){
//Update onClick for the add button
addButton.onclick=function () {
//location.href = 'www.example.com';
window.location="www.example.com";
};
addButton.html("aNewName");
}
}
Based on all the sources either location.href or window.location should redirect me to a different page (in my case just a different subpage) but it does not. After hours of research I thought that I get a wrong button or sth is wrong with the ajax itself but then I added addButton.html line and this works well. What do I do wrong here?