简体   繁体   English

完整的网站版本未在Firefox中加载

[英]Full website version didn't load in Firefox

i have responsible mobile version where are button "go to desktop version": 我有负责任的移动版本,其中的按钮“转到桌面版本”:

<div class="desktop_version">
  <a href="#" onclick="submitinfo();"><em class="fa fa-desktop"></em> Desktop version</a>
</div>

after submit i need send value to mobile.php (ajax) and set $_SESSION['mobile_style']. 提交后,我需要将值发送到mobile.php(ajax)并设置$ _SESSION ['mobile_style']。 jQuery code: jQuery代码:

function submitinfo() {
  $.ajax({
  type: "POST",
  url: "/mobile.php", 
  data: {values:"mobile"}
  });
  window.location.href = "http://dekstopversionexample.lt";
}

and mobile.php: 和mobile.php:

session_start();
    $_SESSION['mobile_style'] = $_POST['values'];

it seems as if everything is fine, in responsinator.com with Chrome all good, but in Fiefox i got error POST http://myaddress.lt/mobile.php . 似乎一切正常,在带有Chrome的responsinator.com中一切正常,但是在Fiefox中,我收到了错误POST http://myaddress.lt/mobile.php With some mobile device same problem after click button. 对于某些移动设备,单击按钮后会出现相同的问题。 Nothing changes, i cant achieve desktop version and session is not saved. 没有任何变化,我无法实现桌面版本,并且会话未保存。

thank you for the help 感谢您的帮助

You need to change window.location in a success callback since it may happen before the asynchronous POST request is finished. 您需要在成功回调中更改window.location,因为它可能在异步POST请求完成之前发生。

$.ajax({
  type: "POST",
  url: "/mobile.php", 
  data: {values:"mobile"}
  success: function(){
    window.location = "http://dekstopversionexample.lt";
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM