我有登录功能,但登录后不会将用户带到主页 而是显示一个空白页面为什么? 有问题的Ajax:
function Login(){
$.ajax({
url: 'http://creative.coventry.ac.uk/~4078078/moviereviews/v1.0/index.php/user/adduser/'+$("#loginusername").val(),
headers: {authorization:window.btoa($("#loginusername").val()+':'+$("#loginpassword").val())},
contentType: "text",
dataType: 'json',
success: function(data) {
authorisation = window.btoa($("#loginusername").val()+':'+$("#loginpassword").val()); //create a variable to pass to the cookie
createCookie('cookie',authorisation,0); //create our authorisation cookie for the client
alert("Login Successful!");
$("#login").hide(); //hide the login button
$("#logout").show(); //show the logout button
$("#addreview").show(); //show the add a review button
$("#adminpanel").show();//show the admin panel page
$("#loginusername").val(''); //clear the name box
$.mobile.changePage("#home"); //show the menu
},
error: function (response) {
var r = jQuery.parseJSON(response.responseText);
alert("Error:" + r.error.text);
}
});
} 登录表单
<!-- Login Page-->
<div data-role="page" id="login" data-theme="a">
<div data-theme="a" data-role="header" data-theme="a">
<a data-role="button" data-mini="true" data-rel="back" data-theme="a" data-icon="back"
data-iconpos="notext" data-transition="slide"></a>
<h3 class="pagetitle">
Login
</h3>
</div>
<div data-role="content" data-theme="a">
<form id="check-user" class="ui-body ui-body-a ui-corner-all">
<fieldset>
<div data-role="fieldcontain">
<label for="loginusername">Username:</label>
<input type="text" value="" name="loginusername" id="loginusername"/>
</div>
<div data-role="fieldcontain">
<label for="loginpassword">Password:</label>
<input type="password" value="" name="loginpassword" id="loginpassword"/>
</div>
<label><input type="checkbox" id="rememberme" name="checkbox-0" data-role="none"/> Remember me </label>
<input type="button" data-theme="a" onclick="Login()" name="submit" value="Log in">
<a href='#signup' data-role="button"> Sign up</a>
</fieldset>
</form>
</div>
</div>
以及我尝试重定向的页面
<!-- Home -->
...列表视图在这里
该网站可在此进行测试 用户名演示和密码演示 enter link description here 我在登录enter link description here
后尝试加载的页面