Also, how to use the values entered in the popup, in the javascript function: login_request()
which is being called on click, which will send the AJAX request eventually.
Note: The code snippet includes all the fields enclosed in the popup.
<input class="csrf-token" type="hidden" name="authenticity_token" value=""> <div class="form-row clearfix"> <label class="lbl-fld">Email ID</label> <input type="email" name="user[email]" ng-model="loginForm.email" placeholder="me@example.com" ng-required="true"/> <!--<span class="valid-chk">--> <!--<i ng-class="{'false':'icon-close', 'true': 'icon-correct'}[form['user[email]'].$valid]"></i>--> <!--</span>--> </div> <div class="form-row clearfix"> <label class="lbl-fld">PASSWORD</label> <input type="password" name="user[password]" placeholder="password" ng-required="true"/> <!--<span class="valid-chk">--> <!--<i ng-class="{'false':'icon-close', 'true': 'icon-correct'}[form['user[password]'].$valid]"></i>--> <!--</span>--> </div> <div class="btn-container clearfix"> <div class="btn-wrap"> <input type="submit" name="commit" value="LOGIN" ng-click="login_request()" /> </div> <div class="loader-wrapper" ng-show="loading" style="bottom: 25px;left: -53px;position: absolute;width: 25px;"> <img class="loader-img-common" src="<%= asset_path('loader.gif') %>" style="max-width: 100%;" /> </div> </div>
Thanks.
function login_request(data_to_send)
{
$.ajax({
type: 'post',
url: 'controller/action',
data: { key: "value" key_1: "value_1" },
success: function(data) {
// paste your code here after success
}
});
}
#in your config/route.rb
match 'controller/action', :to => 'controller#action' ,:via => [:get,:post] # i'm using get as well as post also.
#hope that help you. if you face any problem please let me know
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.