简体   繁体   English

XMLHttpRequest不适用于移动设备上的chrome

[英]XMLHttpRequest is not working on chrome on mobile device

I am working on core javascript on front end and php in back end and for sending and receiving data from back end, I am using XMLHttpRequest. 我正在前端的核心javascript和后端的php以及从后端发送和接收数据,我正在使用XMLHttpRequest。 My code for post request is: 我的帖子请求代码是:

 var request = new XMLHttpRequest(); request.open('POST', BASE_URL+'index.php/dashboard/saveEndPoint'); request.setRequestHeader('Content-Type', 'application/json'); var messageObj = { endPoint: endPoint, ipAddress:userip, url:window.location.href, browser:"Chrome" } request.send(JSON.stringify(messageObj)); 

This code working fine in chrome and firefox on desktop devices. 此代码在桌面设备上的chrome和firefox中运行良好。 But when I am using chrome on mobile devices with android operating system, It's not working. 但是当我在带有Android操作系统的移动设备上使用chrome时,它无法正常工作。 Not sending request. 不发送请求。
I debug code by connecting mobile device with desktop chrome(crome://inspect) but it is showing no request. 我通过将移动设备与桌面chrome(crome:// inspect)连接来调试代码,但它没有显示任何请求。

Help me to find its solution. 帮我找到解决方案。 Thank you in advance. 先感谢您。

I found the problem for not working of my code. 我发现我的代码没有工作的问题。 It is due if-else condition in which, I put this code and because of not able to identify chrome on mobile with my if condition, It is not running ajax code. 这是因为if-else条件,我把这个代码和因为无法使用我的if条件识别移动设备上的chrome,它没有运行ajax代码。

So thank you the scion and everyone to help me find solution. 所以,谢谢你的接穗,大家帮我找到解决方案。

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

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