You are about to use sweetalert2. You want to use the <a href="""</a> tag to display and process the window...

Asked 2 years ago, Updated 2 years ago, 48 views

After all, it's JavaScript

<ahref="/username_input.html">Enter the visitor name.</a>

As shown above, I want to use sweetalert2 (JavaScript) in the get method using a tag.

How do I implement it...

<a data-remote="true" href="https://hashcode.co.kr/user/info?property=organization">modify</a>

Like the hash code site, in the same way as above...

When I try to access the above address directly, an error page appears, so I wonder if it's a POST method. (The server is using node.js.)

I'd appreciate your help!

sweetalert2 node.js

2022-09-22 21:56

1 Answers

In the case of Hashcode, to show the user's information (the value filled in the input) when you click the belonging, you call the url with Ajax to pop up. If you don't have to show the user information value, you don't have to bring it to get.

To simply float a seetalert without getting the user's information, I think you can put a click event on the button or link and float a seetalert.

 <a href="#"class="input-user-name" data-user-id="1">Enter visitor name</a>


  <script>
  $('a.input-user-name').click(function() {
    var userId = $(this).attr("data-user-id");
    showInputalert (userId);
  });

  function showInputalert(userId) {
    swal({
    title: 'Please enter a name',
    type: "input",
    showCancelButton: true,
   confirmButtonText: 'Send',
   preConfirm: function() {
     return new Promise(function(resolve) {
      $.ajax({
// Press Transfer to insert the code you want to transfer to the url.    })
     });
   },
  allowOutsideClick: false
    }, }, function() {

      .done(function(data) {
           //Process when successful 
    swal ("successful", "updated successfully", "success"));
      })
      .error(function(data) {
    //Take care of failure
    swal("");
      });
    });
  }
  </script>


2022-09-22 21:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.