Должно появиться сообщение, когда я нажимаю на кнопку «Отправить повторно». - PullRequest
0 голосов
/ 27 сентября 2018

Это моя кнопка

<button id="resend-invitation-button-<?php echo $user['id'] ?>"
class="btn btn-warning cp_width_100pct resend-invitation-button height_36px"rel="<?php echo $user['email'] ?>"><?php echo $this->translate->_("invite_again") ?></button

Это информационное сообщение

<div id="user-invited-message-<?php echo $user['id']?>" class="alert alert-success org-user-messages" role="alert" style="display: none"><?php echo $this->translate->_("message_user_invited") ?></div>

Это мой вызов ajax Когда я нажимаю кнопку «Пригласить снова», должно отображаться информационное сообщение «Приглашено успешно» **

$('.resend-invitation-button').click(function() {
    var email = $(this).attr('rel');
    var data = {
    email: email
    };
    console.log(data);
    $.ajax("/organization/users/resendinvite",{
    type: "POST",
    data: data       
    })
    .done(function(response) {
      console.log(response);
      if(response == 200) {
          $('.org-user-messages').hide();
          $('#user-invited-message-' + email).show();
          $('#orgstatus-span-' + userId).text("INVITED SUCCESSFULLY");
      }
      if(response == 404){
          $('.org-user-messages').hide();
      }
      if(response == 500){
          $('.org-user-messages').hide();
          $('#user-error-message-' + email).show();
      }
    })
    .fail(function(response) {
      console.log('FAILURE');
    });
});

1 Ответ

0 голосов
/ 27 сентября 2018
<div class="the-return">

  [HTML is replaced when successful.]

</div>



<script type="text/javascript">

$("document").ready(function(){

  $(".js-ajax-php-json").click(function(){
    var data = {
      "action": "test"
    };
    data = $(this).serialize() `enter code here`+ "&" + $.param(data);
    $.ajax({
      type: "POST",
      dataType: "json",
      url: "response.php", //Relative or absolute path to response.php file
      data: data,
      success: function(data) {
        $(".the-return").html(
          "Favorite beverage: " + data["favorite_beverage"] + "<br />Favorite restaurant: " + data["favorite_restaurant"] + "<br />Gender: " + data["gender"] + "<br />JSON: " + data["json"]
        );
        alert("Form submitted successfully.\nReturned json: " + data["json"]);
      }
    });
    return false;
  });
});
</script>
...