ajax谷歌浏览器没缓存,从缓存AJAX请求会导致Chrome(Prevent Chrome from caching AJA

我设置一个应用程序,它可以在Opera和Firefox很棒,但在谷歌浏览器其缓存AJAX请求,并给陈旧的数据!

http://gapps.qk.com.au是应用程序。 当Chrome浏览器,它甚至不发送AJAX请求,但在另一个浏览器尝试时它总是AJAX请求并返回数据。

有没有什么方法(阿帕奇/ PHP / HTML / JS),从这样的行为阻止Chrome浏览器?

Ajax调用:

function sendAjax(action,domain,idelement) {

//Create the variables

var xmlhttp,

tmp,

params = "action=" + action

+ "&domain=" + encodeURIComponent(domain)

xmlhttp = new XMLHttpRequest();

//Check to see if AJAX request has been sent

xmlhttp.onreadystatechange = function () {

if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {

$('#'+idelement).html(xmlhttp.responseText);

}

};

xmlhttp.open("GET", "ajax.php?"+params, true);

xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

//console.log(params);

xmlhttp.send(params);

}

sendAjax('gapps','example.com','gapps');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
A: <!DOCTYPE html> <html> <head> <title>Login Page</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Include Bootstrap stylesheet --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!-- Include jQuery library --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- Include Bootstrap javascript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script> $(document).ready(function(){ $("#login_btn").click(function(){ var username = $("#username").val(); var password = $("#password").val(); $.ajax({ url: "backend.php", type: "POST", data: {username:username, password:password}, success: function(response){ if(response == "success"){ window.location.href = "home.html"; }else{ alert("Invalid username or password!"); } }, error: function(){ alert("Error occured while processing request!"); } }); }); }); </script> </head> <body> <div class="container"> <h2>Login</h2> <form> <div class="form-group"> <label for="username">Username:</label> <input type="text" class="form-control" id="username" placeholder="Enter username"> </div> <div class="form-group"> <label for="password">Password:</label> <input type="password" class="form-control" id="password" placeholder="Enter password"> </div> <button type="button" class="btn btn-primary" id="login_btn">Submit</button> </form> </div> </body> </html> Note: This is just an example HTML code. You need to replace backend.php with your actual backend URL and implement the backend API for processing login credentials. Also, make sure to implement proper security measures to prevent attacks like SQL injection and XSS.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值