我正在使用一个在framework7中构建的移动应用程序模板来开发我的应用程序在cordova上,我需要在每个页面上发出ajax请求以从php web服务获取其数据。我取得了index.html页面一个请求并能正常工作,而不是工作时尝试了同样的要求复制到另一个页面Ajax请求只工作在索引页面
这里是index.html的
function SignIn() {
var UserName = $("input[name=\"UserName\"]").val();
var Password = $("input[name=\"Password\"]").val();
$.ajax({
type : "POST",
url : 'http://example.com/index.php/mobile/users/login/' + UserName + '/' + Password,
contentType: "application/json; charset=utf-8",
dataType : 'json',
cache: false,
success: function(data) {
if(data == 'true')
{
document.location = "home.html";
}else{
document.getElementById('reslt').style.display = "block";
$("#reslt").html('Username or password incorrect..!');
}
},
error: function(req, err){ console.log('my message : ' + err); }
});
};
这里是另一页是请求没有工作
function SignIn() {
var UserName = $("input[name=\"UserName\"]").val();
var Password = $("input[name=\"Password\"]").val();
$.ajax({
type : "POST",
url : 'http://example.com/index.php/mobile/users/login/' + UserName + '/' + Password,
contentType: "application/json; charset=utf-8",
dataType : 'json',
cache: false,
success: function(data) {
if(data == 'true')
{
document.location = "home.html";
}else{
document.getElementById('reslt').style.display = "block";
$("#reslt").html('Username or password incorrect..!');
}
},
error: function(req, err){ console.log('my message : ' + err); }
});
};
任何想法尝试?