[Hỏi đáp] Hi i write from Mexico

  Bài viết hay nhất1
Hi my friends i read your forum since 2 years ago, i'ts a excellent site, i use this thread several times to write my own codes

http://devs.forumvi.com/t520-gist-mot-so-cach-dung-ajax-trong-forumotion

but now is gone :( can you help me?

i want work in this zone

   /contact

how is the $.post elements to send?


sorry my english is ugly and i'm not speak Vietnamese, but google tanslator help very well :)
Tags: #javascript
  Bài viết hay nhất2
See that post here: http://devs.forumvi.com/t520-tip-mot-so-cach-dung-ajax-trong-forumotion?showpost=p3139

For example, quick contact with the title and content by default:
Code:
<form id="quickContact">
    <div id="addEmail"></div>
    <img src="/antirobot_pic.forum?a=1" alt="regkey" style="vertical-align: middle;" />
    <input id="reg_key" type="key" name="reg_key" size="5" required />
    <input type="submit" value="Submit" name="submit" />
</form>
<script>
    if (_userdata.session_logged_in === 0) { // Not login

        $('#addEmail').html('<label>Email: <input type="email" name="email" id="email" placeholder="Enter your email" required /></label>');
    }

    $('#quickContact').on('submit', function(e) {
        e.preventDefault();

        var config = {
            subject: "Message title",
            message: "Message contents",
            reg_key: $('#reg_key').val(),
            action: "submit"
        };


        if (_userdata.session_logged_in === 0) { // Not login
            config.email = $('#email').val();
        }

        $.post("/contact", config).done(function(data) {
            if ($(data).find('.msg').find('p.center:contains("Your message has been forwarded on to the staff of the forum")').length) {
                alert('Success');
            }
            // alert('Done');
        }).fail(function() {
            // alert('Fail');
        }).always(function() {
            $('#reg_key, #email').val('');
            // alert('Done or Fail');
        });
    });
</script>

Demo: http://devs.forumvi.com/h25-quick-contact
  Bài viết hay nhất3
oh i see, thanks so much!!!!
  Bài viết hay nhất4
i try in modal way but not work

Code:

$('a[href="/contact"]').on('click', function (o) {
    o.preventDefault();
    $(document.body).prepend('<form id="quickContact" class="report"><h1 style="font-size: 14px;text-align: center;font-family: monda;"><img style="width: 20px;vertical-align: middle;" src="http://i18.servimg.com/u/f18/19/17/54/05/logoti10.png">Contacta con Open Source</h1> <fieldset>  <dl><dt><label for="subject">Tema del mensaje<span class="obligatory">*</span>:</label></dt> <dd> <input type="text" name="subject" id="subject" maxlength="52" class="inputbox" value=""> </dd> </dl> </fieldset> <fieldset> <dl><dt><label for="message">Contenido de Mensaje.<span class="obligatory">*</span>:</label></dt> <dd> <textarea cols="25" rows="10" name="message" id="message" class="inputbox"></textarea> </dd> </dl> </fieldset> <fieldset> <dl><dt><label for="reg_key">Código de confirmación<span class="obligatory">*</span>:</label></dt> <dd class="captcha"> <div class="captcha-img"> <label for="reg_key" dir="ltr"> <img src="/antirobot_pic.forum?a=1" alt="regkey" style="vertical-align: middle;" /></label> <input type="hidden" name="username" value=""> <input type="hidden" name="time" value=""> </div> <input class="inputbox tiny" type="text" name="reg_key" id="reg_key" maxlength="5" dir="ltr"> </dd> </dl> </fieldset><fieldset id="addEmail"></fieldset><fieldset class="submit-buttons"> <input type="submit" value="Enviar" name="submit"> </fieldset> </form>');
    if (_userdata.session_logged_in === 0) {

        $('#addEmail').html('<dd><dl><label>Email: <input type="email" name="email" id="email" placeholder="Enter your email" required /></label></dt></dl>');
    }

    $('#quickContact').find('.contact_ajax_input').on('submit', function (e) {
        e.preventDefault();
        var config = {
            subject:  $('#subject').val(),
            message: $('#message').val(),
            reg_key: $('#reg_key').val(),
            action: "submit"
        };
        if (_userdata.session_logged_in === 0) { // Not login
            config.email = $('#email').val();
        }
        $.post("/contact", config).done(function (data) {
            $('#subject').add('#message').add('#reg_key').val("")
            if ($(data).find('.panel').find('p.center:contains("Tu mensaje ha sido transmitido con éxito. Será leído lo más pronto posible.")').length) {
                alert('Success');
            }
        })

    });
});


what is wrong?

Code:

#quickContact{
color:#fff;
position:fixed;
background:rgba(0, 0, 0, 0.71);
height:400px;
width:500px;
top:25%;
left:30%;
z-index:999;
padding:10px;
border-radius:3px;

}
#quickContact label{color:#fff}

#quickContact h1{font-size:14px!important}
  Bài viết hay nhất5
What's your forum? and demo?
  Bài viết hay nhất6
forum:
  Bài viết hay nhất7
Code:
$('a[href="/contact"]').on('click', function(o) {
   o.preventDefault();

   if ($('#quickContact').length) {
      $('#quickContact').fadeIn();
   } else {
      $(document.body).prepend('<form id="quickContact" class="report"><h1 style="font-size: 14px;text-align: center;font-family: monda;"><img style="width: 20px;vertical-align: middle;" src="http://i18.servimg.com/u/f18/19/17/54/05/logoti10.png">Contacta con Open Source</h1> <fieldset>  <dl><dt><label for="subject">Tema del mensaje<span class="obligatory">*</span>:</label></dt> <dd> <input type="text" name="subject" id="subject" maxlength="52" class="inputbox" value=""> </dd> </dl> </fieldset> <fieldset> <dl><dt><label for="message">Contenido de Mensaje.<span class="obligatory">*</span>:</label></dt> <dd> <textarea cols="25" rows="10" name="message" id="message" class="inputbox"></textarea> </dd> </dl> </fieldset> <fieldset> <dl><dt><label for="reg_key">Código de confirmación<span class="obligatory">*</span>:</label></dt> <dd class="captcha"> <div class="captcha-img"> <label for="reg_key" dir="ltr"> <img src="/antirobot_pic.forum?a=1" alt="regkey" style="vertical-align: middle;" /></label> <input type="hidden" name="username" value=""> <input type="hidden" name="time" value=""> </div> <input class="inputbox tiny" type="text" name="reg_key" id="reg_key" maxlength="5" dir="ltr"> </dd> </dl> </fieldset><fieldset id="addEmail"></fieldset><fieldset class="submit-buttons"> <input type="submit" value="Enviar" name="submit"> </fieldset> </form>');
   }

   if (_userdata.session_logged_in === 0) {
      $('#addEmail').html('<dd><dl><label>Email: <input type="email" name="email" id="email" placeholder="Enter your email" required /></label></dt></dl>');
   }

   $('#quickContact').on('submit', function(e) {
      e.preventDefault();

      var config = {
         subject: $('#subject').val(),
         message: $('#message').val(),
         reg_key: $('#reg_key').val(),
         action: "submit"
      };

      if (_userdata.session_logged_in === 0) {
         config.email = $('#email').val();
      }

      $.post("/contact", config).done(function(data) {
         if ($(data).find('.panel').find('p.center:contains("Tu mensaje ha sido transmitido con éxito. Será leído lo más pronto posible.")').length) {
            alert('Success');
         }
      }).always(function() {
         $('#subject, #message, #reg_key, #email').val('');
         $('#quickContact').fadeOut();
      });

   });
});
  Bài viết hay nhất8
thanks my friend i learn something every day
  Bài viết hay nhất9
You cannot reply to topics in this forum