0

hello i am trying to redirect to another webapage but its not working:

code which written to redirect:

  window.location.replace = "/goal/viewgoal/goalID";

html code:

   <button id="submit-new-goal"class="btn btn-sm btn-primary m-l-md redirect">
     Continue Save
   </button>

complete code:

  if (!checkValidation) {
  $.ajax({
    url: "/goal/createGoal",
    type: "POST",
    dataType: "json",
    data: {
      goalSchemaObj,
      userID,
      selectedTeachers
    },
    success: function(data) {
      console.log("created Goal", data);
      $.bootstrapGrowl("<h4>Success!</h4><p>Goal Created.</p>", {
        type: "success",
        delay: 4500,
        allow_dismiss: true
      });
       window.location.replace = "/goal/viewgoal/goalID";
    },
    error: async err => {
      const response = await err;
      console.log("creation-cehck", response);
      $.bootstrapGrowl("<h4>Error!</h4><p>something wrong.</p>", {
        type: "danger",
        delay: 4500,
        allow_dismiss: true
      });
    }
  });
} else {
  $.bootstrapGrowl("<h4>warning!</h4><p>Please Fill all the fields.</p>", {
    type: "warning",
    delay: 4500,
    allow_dismiss: true
  });
}
dev
  • 3
  • 5

1 Answers1

0

use

window.location.replace('url');

instead

window.location.replace='url';
  • I see you attempted to edit the question to make it look like a closed as duplicate - that is not how this works, by voting to close that automatically adds that "edit" to the question when enough people vote that way. – Mark Schultheiss Nov 17 '19 at 11:46
  • now its using this id "http://localhost:3000/goal/viewgoal/goalID" not saving it inti db – dev Nov 17 '19 at 11:49