Tags » JQuery

jQuery UI's Widget Factory for Stateful Plugins

The ability to create widgets using jQuery UI’s widget factory is incredibly useful, especially when your project’s front-end code is highly dependent on jQuery. The jQuery UI Widget Factory is a component of the… 1,136 more words

JQuery

Help with ASP.NET MVC controller actions that return JSON

I found a couple of issues implementing MVC ajax GET calls with JQuery that caused me headaches so sharing solutions here.

1. Make sure to include the data type “json” in the ajax call. 172 more words

JavaScript

Random Integer Generator

function randomInt(min, max) {
return (Math.floor(Math.random() * (max – min + 1)) + min);
}

Jquery

Number Animation using jQuery

Number is an important value that we could see in many places, Just a try to make that number look awesome. DEMO

$(function(){
  $('.count').each(function () {
    $(this).prop('Counter',0).animate({
        Counter: $(this).text()
    }, {
        duration: 2000,
        easing: 'swing',
        step: function (now) {
            $(this).text(Math.ceil(now));
        }
    });
   });
});
JavaScript

Week 7: Wrap-up

Javascript, jQuery and Objects

This week was interesting. After having breezed through last week with some introductory material to HTML/CSS and Javascript, things ramped up big time when we went in depth with… 952 more words

Launch

Week 1: JavaScript, jQuery, and some SQL

Week one of coding bootcamp is officially over. *Takes deep breath.* Just 11 more weeks to go!

This week was hectic to say the least. Between the insane amount of time spent commuting, and the 12~ hours a day I spent on campus, there was barely any time left to breathe. 424 more words

Coding

Ajax Email Send in Codeigniter


// routes

$route['admin/objednavka/send_email'] = "backend/order/send_email";

// html 


     Email: 
    <input id="user_email" type="hidden" name="user_email" value="getsolved@gmail.com">
</div>


     Subject: 
    <input id="user_email_sub" type="text" name="user_email_sub" value="getsolved@gmail.com">
</div>


     body: 
    <textarea id="user_email_body" type="text" name="user_email_body">
    </textarea>
</div>


    
      
        Send Order Email
    
</div>


    
    
       assets/backend/img/preloader.gif" width="100%">
    
</div>

// jquery 

$("#sendOrderEmail").click(function () {

    var url = $(".url").val();
    var email = $('#user_email').val();
    var user_email_sub= $('#user_email_sub').val();
    var user_email_body= $('#user_email_body').val();

    // alert(email + email_type)
    $.ajax({
        url: url + "admin/objednavka/send_email",
        // url: url + "backend/order/send_email",
        type: 'post',
        data: { 
             'user_email_sub': user_email_sub,  
             'email': email, 
             'user_email_body': user_email_body 
        },
        dataType: 'json',
        beforeSend: function () {
            $("#loading").show();
        },
        success: function (json) {
            
            if (json.success) {
                alert('Email Successfully Sent')
            }
            $("#loading").hide();
            
        },
        error: function (request, status, error) {
            alert("Nepodařilo se změnit.");
            $("#loading").hide();
        }
    });
});

// controller
class Order extends Base_backend
{

    public function __construct()
    {
        parent::__construct();

        $this->load->library('layout');
        $this->layout->title('Objadnávka | Weboo Shop 2.0');
        $this->load->library('form_validation');

        $this->menuOpen->m_order = 1;
    }

    public function sendEmailBackend($to, $subject, $body)
    {
        $sender = $this->setting_model->get_setting("email", "sender", DEFAULT_LANG)->value;
        $senderName = $this->setting_model->get_setting("email", "sender-name", DEFAULT_LANG)->value;

        include_once APPPATH.'/libraries/phpmailer/PHPMailerAutoload.php';
        $mail = new PHPMailer;

        $mail->isSMTP();                            // Set mailer to use SMTP
        $mail->Host = _s("mail-server");            // Specify main and backup SMTP servers
        $mail->SMTPAuth = true;                     // Enable SMTP authentication
        $mail->Username = _s("mail-login");         // SMTP username
        $mail->Password = _s("mail-password");      // SMTP password
        $mail->SMTPSecure = 'ssl';                  // Enable TLS encryption, `ssl` also accepted
        $mail->Port = _s("mail-port");              // TCP port to connect to
        $mail->CharSet = 'UTF-8';
        
        $mail->setFrom(_s("mail-login"), $senderName);
        $mail->addAddress($to);     
        $mail->addReplyTo($sender, $senderName);

        $mail->isHTML(true);                         // Set email format to HTML

        $mail->Subject = $subject;
        $mail->Body = $body;
        $mail->AltBody = $body;
        $mail->send();

        return 1;
    }

    public function send_email()
    {
        $item = $_POST['email_type'];
        $email_text  = $this->b_order_model->get_email_text_by_status($item);

        $email = $_POST['email'];
        $user_email_sub= $_POST['user_email_sub'];
        $user_email_body = $_POST['user_email_body '];

        $status = $this->sendEmailBackend($email,$user_email_sub, $user_email_body );

        echo json_encode(['success' => 1,'status' => $status]);
    }
} 146 more words
Programming