Home > front end > Button on the ajax request is less than the controller inside
Button on the ajax request is less than the controller inside
Time:09-17
front-end code
Id="BTN" onclick="time" (this) & gt; Get verification code
the ajax request, here is layui framework
<script SRC="https://bbs.csdn.net/topics/resource/layuiadmin/layui/layui.js" & gt; </script> <script> Layui. Config ({ Base: 'the resource/layuiadmin///static resource path }). The extend ({ Index: 'lib/index//the main entry module }). Use ([' index ', 'user'], function () { Var $=layui. $ , the setter=layui setter Admin=layui. Admin , form=layui. Form , the router=layui. The router () , search=the router. The search;
form.render();
//$(" body ") on (" click ", "# get - vercode", function () { //alert (1); //});
$(" # get - vercode "). Click (function () { This. SRC="https://bbs.csdn.net/topics/system/admin/validateCode? T="+ (new Date). GetTime (); });
//submit Form. On (' submit (user - login - submit), function (data) {
The doLogin (data field);
});
/* * * deposit characters form * @ returns */
The function the doLogin (params) { Var index=layer. The load (1, 0.7} {shade:); $. Ajax ({ Type: "post", Url: 'the system/admin/the dologin', DataType: "json", Traditional: true, //set the contentType type to json //contentType: 'application/json; Charset=utf-8 ', //the json data Data: params, //callback function after the request is successful Success: the function (data) { layer.close(index); If (data. Success) {
Layer. MSG (data. MSG, { Offset: 'auto' 1 , icon:Shade: 0.3 , shadeClose: true The anim: 1 Time: 2000 }, The function () { The location. The href='https://bbs.csdn.net/system/admin/index'; });