我使用笨,和jQuery的Forrm插件:http://malsup.com/jquery/form/笨的Ajax表單提交
我有一個問題得到一個表格才能正常工作。
查看
<div class="row">
<div class="well col-sm-5 col-sm-offset-3">
<h2><span class="fa fa-key"></span> Please login below</h2>
<form class="form-horizontal" id="LoginForm" role="form" method="post" action="/login_controller/process" onsubmit="PostFormRedirect('#LoginForm', '#RetMsg', '/');return false;">
<div class="row small-pad">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-inbox" style="max-width:20px;min-width:20px;"></i></span>
<input type="email" class="form-control" id="UserName" name="UserName" placeholder="Email" />
</div>
</div>
<div class="row small-pad">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key" style="max-width:20px;min-width:20px;"></i></span>
<input type="password" class="form-control" id="UserPass" name="UserPass" placeholder="Password" />
</div>
</div>
<div class="row small-pad">
<button type="submit" class="btn btn-primary pull-right"><span class="fa fa-sign-in"></span> Sign in</button>
</div>
<div class="row small-pad center-text">
<a href="/forgot" class="is-ajax-inner" data-where="#RetMsg">Forgot My Password</a>
</div>
</form>
<div id="RetMsg"></div>
</div>
</div>
控制器
class Login_controller extends CI_Controller {
public function __construct(){
$this->load->database();
var_dump('loaded');
exit;
}
public function process(){
$this->load->model('login_model');
$this->login_model->process();
}
}
型號
class Login_model extends CI_Model {
function process(){
var_dump('YEP');
exit;
}
}
PostFormRedirect功能
function PostFormRedirect(FormID, Target, Location){
try{
$subButton = jQuery('[type="submit"]');
var options = {
target: Target,
beforeSubmit: function() {
$subButton.attr('disabled', 'disabled');
jQuery(Target).html('<div class="pageLoader">Loading...<br /><img src="/assets/images/ajax-loader.gif" alt="loading..." height="11" width="16" /></div>');
jQuery(Target).slideDown('fast');
},
success: function (html) {
setTimeout(function() {
var $t = Math.round(new Date().getTime()/1000);
jQuery(Target).html(html);
jQuery(Target).slideUp('fast');
if(typeof(Location) !== 'undefined'){
window.location.href = Location + '?_=' + $t;
}
}, 3000);
},
error: function(e){
var $html = e.responseText;
jQuery(Target).html($html);
jQuery(Target).slideDown('fast');
if(jQuery('#captcha-gen').length){
var $t = Math.round(new Date().getTime()/1000);
jQuery.get('/inc/captcha.php?_=' + $t, function(data){
jQuery('#captcha-gen').html(data);
});
}
$subButton.removeAttr('disabled');
}
};
jQuery(FormID).ajaxSubmit(options);
}catch(err){
alert(err.message);
}
}
的.htaccess
# The Friendly URLs part - for normal pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA,NC]
的config/routes.php文件
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';
$route['404_override'] = '';
什麼是happenning是,現在,RetMsg
正顯示出我一個404錯誤......我什麼時候才能擺脫404錯誤的, RetMsg
再次向我顯示登錄表單。
我在做什麼錯?我期望它給我看var_dump('YEP');
的問題可能是你的'routes.php' –